Advertisement
jdalbey

add random number of buttons

May 18th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1.  
  2. import java.awt.BorderLayout;
  3. import java.awt.Dimension;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import javax.swing.BoxLayout;
  7. import javax.swing.JButton;
  8. import javax.swing.JFrame;
  9. import javax.swing.JPanel;
  10.  
  11. public final class GUI extends JFrame
  12. {
  13. private JButton submit;
  14. private JPanel btnList;
  15.  
  16. public GUI()
  17. {
  18. setLayout(new BorderLayout());
  19. JPanel content = new JPanel();
  20. content.setLayout(new BorderLayout());
  21. content.setPreferredSize(new Dimension(200, 300));
  22. this.getContentPane().add(content);
  23.  
  24. btnList = new JPanel();
  25. btnList.setLayout(new BoxLayout(btnList, BoxLayout.PAGE_AXIS));
  26.  
  27. submit = new JButton("Get Random");
  28.  
  29.  
  30. //Add Components to this container
  31. content.add(submit, BorderLayout.NORTH);
  32. content.add(btnList, BorderLayout.CENTER);
  33. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  34. pack();
  35. }
  36.  
  37. private void makeButtons(int number)
  38. {
  39. validate();
  40. }
  41.  
  42. public static void main(String[] args)
  43. {
  44. //Schedule a job for the event-dispatching thread:
  45. //creating and showing this application's GUI.
  46. javax.swing.SwingUtilities.invokeLater(new Runnable()
  47. {
  48. public void run()
  49. {
  50. //Create and set up the content pane.
  51. GUI frame = new GUI();
  52. frame.setVisible(true);
  53. }
  54. });
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement