Created
April 22, 2018 18:57
-
-
Save kishida/08aa2a7d7ddbdddabe78a3afd0646cea to your computer and use it in GitHub Desktop.
Simple JFrame sample
This file contains hidden or 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
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