Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. import java.awt.BorderLayout;
  2. import java.awt.EventQueue;
  3.  
  4. import javax.swing.JFrame;
  5. import javax.swing.JPanel;
  6. import javax.swing.border.EmptyBorder;
  7. import javax.swing.JButton;
  8.  
  9. import java.awt.event.ActionListener;
  10. import java.awt.event.ActionEvent;
  11.  
  12.  
  13. public class Main extends JFrame {
  14.  
  15. public static JPanel mainPane;
  16. public final JButton menuButton = new JButton("New button");
  17.  
  18. /**
  19. * Launch the application.
  20. */
  21. public static void main(String[] args) {
  22. EventQueue.invokeLater(new Runnable() {
  23. public void run() {
  24. try {
  25. Main frame = new Main();
  26. frame.setVisible(true);
  27. } catch (Exception e) {
  28. e.printStackTrace();
  29. }
  30. }
  31. });
  32. }
  33.  
  34. /**
  35. * Create the frame.
  36. */
  37. public Main() {
  38. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  39. setBounds(100, 100, 450, 300);
  40. mainPane = new JPanel();
  41. mainPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  42. setContentPane(mainPane);
  43. mainPane.setLayout(null);
  44. menuButton.addActionListener(new ActionListener() {
  45. public void actionPerformed(ActionEvent arg0) {
  46. Menu.main(String[] args);
  47. }
  48. });
  49. menuButton.setBounds(76, 89, 104, 32);
  50. mainPane.add(menuButton);
  51. }
  52. }
  53.  
  54. import java.awt.BorderLayout;
  55. import java.awt.EventQueue;
  56.  
  57. import javax.swing.JFrame;
  58. import javax.swing.JPanel;
  59. import javax.swing.border.EmptyBorder;
  60. import javax.swing.JLabel;
  61.  
  62.  
  63. public class Menu extends JFrame {
  64.  
  65. public static JPanel menuPane;
  66.  
  67. /**
  68. * Launch the application.
  69. */
  70. public static void main(String[] args) {
  71. EventQueue.invokeLater(new Runnable() {
  72. public void run() {
  73. try {
  74. Menu frame = new Menu();
  75. frame.setVisible(true);
  76. } catch (Exception e) {
  77. e.printStackTrace();
  78. }
  79. }
  80. });
  81. }
  82.  
  83. /**
  84. * Create the frame.
  85. */
  86. public Menu() {
  87. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  88. setBounds(100, 100, 450, 300);
  89. menuPane = new JPanel();
  90. menuPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  91. setContentPane(menuPane);
  92. menuPane.setLayout(null);
  93.  
  94. JLabel menuTitle = new JLabel("Menu");
  95. menuTitle.setBounds(194, 11, 46, 14);
  96. menuPane.add(menuTitle);
  97.  
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement