Skip to content

Instantly share code, notes, and snippets.

@sshine

sshine/Derp.java Secret

Last active November 23, 2020 04:08
Show Gist options
  • Save sshine/f40edf5ccf4f416f0953a5f9af789d1c to your computer and use it in GitHub Desktop.
Save sshine/f40edf5ccf4f416f0953a5f9af789d1c to your computer and use it in GitHub Desktop.
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