-
-
Save sshine/f40edf5ccf4f416f0953a5f9af789d1c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.*; | |
import java.util.List; | |
import java.util.ArrayList; | |
import java.util.Scanner; | |
public class GUI { | |
public static JFrame window; | |
public static void main(String[] args) { | |
window = new JFrame("To do"); | |
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
window.setLayout(new FlowLayout()); | |
window.setSize(800, 600); | |
window.setVisible(true); | |
addButton(); | |
} | |
public static void addButton() { | |
JButton button = new JButton("Click me!"); | |
button.addActionListener(new ActionListener() { | |
public void actionPerformed(ActionEvent e) { | |
System.out.println("Yes, this does trigger."); | |
addButton(); | |
} | |
}); | |
window.getContentPane().add(button); | |
window.repaint(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment