Skip to content

Instantly share code, notes, and snippets.

@kishida
Created April 22, 2018 18:57
Show Gist options
  • Save kishida/08aa2a7d7ddbdddabe78a3afd0646cea to your computer and use it in GitHub Desktop.
Save kishida/08aa2a7d7ddbdddabe78a3afd0646cea to your computer and use it in GitHub Desktop.
Simple JFrame sample
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class MyFrame {
public static void main(String[] args) {
JFrame f = new JFrame("test");
JTextArea ta = new JTextArea();
f.add(ta);
JButton b = new JButton("Hello");
b.addActionListener(al -> ta.append("Hello!!\n"));
f.add(BorderLayout.NORTH, b);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(500, 400);
f.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment