Swing1.java 575 B

1234567891011121314151617181920212223
  1. import javax.swing.JButton;
  2. import javax.swing.JFrame;
  3. import javax.swing.JLabel;
  4. import javax.swing.JPanel;
  5. public class Main {
  6. public static void main(String[] args) {
  7. JFrame frame = new JFrame("My title!");
  8. frame.setVisible(true);
  9. frame.setSize(300, 150);
  10. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  11. JPanel panel = new JPanel();
  12. frame.add(panel);
  13. JLabel label = new JLabel("my label");
  14. panel.add(label);
  15. JButton button = new JButton("my button");
  16. panel.add(button);
  17. }
  18. }