1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| package first_gui;
import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.FlowLayout;
public class FirstWindow extends JFrame { private static final long serialVersionUID = 123;
public FirstWindow() { setTitle("First Window"); setSize(400, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout());
JLabel label = new JLabel("Hello GUI!"); add(label);
JButton button = new JButton("First Button"); add(button);
setVisible(true); }
public static void main(String[] args) { new FirstWindow(); } }
|