Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication17;
- import java.awt.Dimension;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import static javax.swing.JFrame.EXIT_ON_CLOSE;
- import javax.swing.JPanel;
- import javax.swing.SwingUtilities;
- import javax.swing.Timer;
- public class JavaApplication17 extends JFrame{
- final JButton submitButton = new JButton("TEST");
- Timer timer;
- public JavaApplication17() {
- initUI();
- }
- private void initUI() {
- JPanel panel = new JPanel();
- getContentPane().add(panel);
- panel.setLayout(null);
- submitButton.setSize(80, 80);
- submitButton.setLocation(20, 20);
- panel.add(submitButton);
- setSize(200, 200);
- setLocationRelativeTo(null);
- setDefaultCloseOperation(EXIT_ON_CLOSE);
- test();
- timer.start();
- }
- public void test(){
- timer = new Timer(18, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- Dimension dim = submitButton.getSize();
- if (dim.getHeight() < 79.9) {
- submitButton.setSize((int) (dim.getWidth() + 6), (int) (dim.getHeight() + 6));
- } else {
- submitButton.setSize(20, 20);
- }
- }
- });
- }
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- JavaApplication17 ex = new JavaApplication17();
- ex.setVisible(true);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement