File tree Expand file tree Collapse file tree 4 files changed +52
-0
lines changed
Expand file tree Collapse file tree 4 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ * .class
Original file line number Diff line number Diff line change 1+ {
2+ "editor.tabSize" : 4 ,
3+ "editor.rulers" : [
4+ 80
5+ ],
6+ "trailing-spaces.trimOnSave" : true ,
7+ "java.project.referencedLibraries" : [
8+ " lib/**/*.jar"
9+ ]
10+ }
Original file line number Diff line number Diff line change 1+ import java .awt .FlowLayout ;
2+
3+ import javax .swing .JButton ;
4+ import javax .swing .JFrame ;
5+ import javax .swing .JLabel ;
6+ import javax .swing .JPanel ;
7+ import javax .swing .JTextField ;
8+
9+ public class HelloWorld {
10+ public static void main (String [] args ) {
11+ JFrame frame = new JFrame ("My application" );
12+ frame .setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE );
13+ frame .setSize (400 , 200 );
14+ frame .setLayout (new FlowLayout ());
15+
16+ JLabel label = new JLabel ("Hello, world!" );
17+ frame .add (label );
18+
19+ JTextField textField = new JTextField (10 );
20+ frame .add (textField );
21+
22+ JButton button = new JButton ("Update" );
23+ button .addActionListener (e -> {
24+ String name = textField .getText ();
25+ label .setText ("Hello, " + name + "!" );
26+ });
27+ frame .add (button );
28+
29+ frame .setVisible (true );
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ # Swing 예제
2+
3+ - < https://docs.oracle.com/javase/tutorial/uiswing/index.html >
4+ - < https://docs.oracle.com/javase/tutorial/uiswing/examples/start/HelloWorldSwingProject/src/start/HelloWorldSwing.java >
5+
6+ ``` bash
7+ javac -d out HelloWorld.java
8+
9+ java --class-path out HelloWorld
10+ ```
You can’t perform that action at this time.
0 commit comments