Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. panel=new JPanel();
  2. add(panel);
  3. panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
  4.  
  5. JButton button1=new JButton("button1");
  6. JButton button2=new JButton("button2");
  7.  
  8. buttonsPanel=new JPanel();
  9. buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
  10.  
  11. buttonsPanel.add(button1, CENTER_ALIGNMENT);
  12. buttonsPanel.add(button2, CENTER_ALIGNMENT);
  13. panel.add(buttonsPanel, BorderLayout.CENTER);
  14.  
  15. buttonsPanel.add(button1, CENTER_ALIGNMENT);
  16.  
  17. panel.add(buttonsPanel, BorderLayout.CENTER);
  18.  
  19. JPanel buttonsPanel = new JPanel();
  20. buttonsPanel.add(button1);
  21. buttonsPanel.add(button2);
  22.  
  23. frame.setLayout( new GridBagLayout() );
  24. frame.add(buttonsPanel, new GridBagConstraints());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement