Advertisement
Crenox

Winston Tutorial 10 GridLayout

Jul 27th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package com.samkough.main;
  2.  
  3. import javax.swing.*;
  4. import java.awt.*;
  5. import java.awt.event.*;
  6.  
  7. @SuppressWarnings("serial")
  8. public class Win extends JFrame
  9. {
  10. private static final int WIDTH = 600;
  11. private static final int HEIGHT = 600;
  12.  
  13. JButton b1, b2, b3;
  14. JLabel l1, l2, l3;
  15.  
  16. public Win()
  17. {
  18. // first is rows, then columns
  19. setLayout(new GridLayout(2, 3));
  20.  
  21. b1 = new JButton("1");
  22. b2 = new JButton("2");
  23. b3 = new JButton("3");
  24. l1 = new JLabel("1");
  25. l2 = new JLabel("2");
  26. l3 = new JLabel("3");
  27.  
  28. add(b1);
  29. add(b2);
  30. add(b3);
  31. add(l1);
  32. add(l2);
  33. add(l3);
  34. }
  35.  
  36. public static void main(String args[])
  37. {
  38. Win frame = new Win();
  39.  
  40. frame.setVisible(true);
  41. frame.setSize(WIDTH, HEIGHT);
  42. frame.setTitle("Tutorial #10");
  43. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  44. frame.setLocationRelativeTo(null);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement