Advertisement
Guest User

Untitled

a guest
May 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4.  
  5. public class BoxLayoutTest extends JFrame implements ActionListener {
  6.  
  7. private JPanel [][] panels;
  8.  
  9. public BoxLayoutTest () {
  10. panels = new JPanel [8][8];
  11. for (int i = 0; i < panels.length; i++) {
  12. for (int j = 0; j < panels[i].length; j++) {
  13. panels[i][j] = new JPanel();
  14. panels[i][j].setSize (60,60);
  15. panels[i][j].setBorder (BorderFactory.createLineBorder (Color.black));
  16. panels[i][j].add (new JLabel ("" + i + "" + j));
  17. }
  18. }
  19.  
  20. panels[0][5].add (new JLabel (new ImageIcon ("C:\\Documents and Settings\\a16488\\Local Settings\\Temporary Internet Files\\Content.IE5\\OBNJOYDB\\cards_gif[1]\\" +
  21. "/cards_gif/c1.gif")));
  22. initStuff();
  23. }
  24.  
  25.  
  26. public void initStuff () {
  27.  
  28. setSize (480,480);
  29. setLocationRelativeTo (null);
  30. setDefaultCloseOperation (DISPOSE_ON_CLOSE);
  31. setTitle ("GOVN");
  32.  
  33. Container pane2 = getContentPane();
  34. JPanel pane = new JPanel();
  35. pane.setLayout (new BoxLayout (pane, BoxLayout.LINE_AXIS));
  36.  
  37. JPanel [] xAxis = new JPanel [8];
  38. for (int i = 0; i < xAxis.length; i++) {
  39. xAxis[i] = new JPanel();
  40. xAxis[i].setLayout (new BoxLayout (xAxis[i], BoxLayout.PAGE_AXIS));
  41. for (int j = 0; j < panels[i].length; j++) {
  42. xAxis[i].add (panels[i][j]);
  43. }
  44. }
  45.  
  46. for (JPanel panel: xAxis) {
  47. pane.add (panel);
  48. }
  49. JPanel scorePanel = new JPanel();
  50. scorePanel.setSize (60, 480);
  51. scorePanel.setLayout (new BoxLayout (scorePanel, BoxLayout.PAGE_AXIS));
  52. scorePanel.add (Box.createVerticalStrut (220));
  53. scorePanel.add (new JLabel ("Score:"));
  54. scorePanel.add (Box.createVerticalStrut (220));
  55. pane.add (scorePanel);
  56.  
  57. // pane.addActionListener (this);
  58.  
  59. pane2.add (pane);
  60.  
  61.  
  62. }
  63.  
  64. public static void main (String [] args) {
  65. BoxLayoutTest test = new BoxLayoutTest();
  66. test.setVisible (true);
  67. }
  68.  
  69. public void actionPerformed (ActionEvent evt) {
  70. System.out.println (evt.getActionCommand());
  71. }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement