Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class BoxLayoutTest extends JFrame implements ActionListener {
- private JPanel [][] panels;
- public BoxLayoutTest () {
- panels = new JPanel [8][8];
- for (int i = 0; i < panels.length; i++) {
- for (int j = 0; j < panels[i].length; j++) {
- panels[i][j] = new JPanel();
- panels[i][j].setSize (60,60);
- panels[i][j].setBorder (BorderFactory.createLineBorder (Color.black));
- panels[i][j].add (new JLabel ("" + i + "" + j));
- }
- }
- panels[0][5].add (new JLabel (new ImageIcon ("C:\\Documents and Settings\\a16488\\Local Settings\\Temporary Internet Files\\Content.IE5\\OBNJOYDB\\cards_gif[1]\\" +
- "/cards_gif/c1.gif")));
- initStuff();
- }
- public void initStuff () {
- setSize (480,480);
- setLocationRelativeTo (null);
- setDefaultCloseOperation (DISPOSE_ON_CLOSE);
- setTitle ("GOVN");
- Container pane2 = getContentPane();
- JPanel pane = new JPanel();
- pane.setLayout (new BoxLayout (pane, BoxLayout.LINE_AXIS));
- JPanel [] xAxis = new JPanel [8];
- for (int i = 0; i < xAxis.length; i++) {
- xAxis[i] = new JPanel();
- xAxis[i].setLayout (new BoxLayout (xAxis[i], BoxLayout.PAGE_AXIS));
- for (int j = 0; j < panels[i].length; j++) {
- xAxis[i].add (panels[i][j]);
- }
- }
- for (JPanel panel: xAxis) {
- pane.add (panel);
- }
- JPanel scorePanel = new JPanel();
- scorePanel.setSize (60, 480);
- scorePanel.setLayout (new BoxLayout (scorePanel, BoxLayout.PAGE_AXIS));
- scorePanel.add (Box.createVerticalStrut (220));
- scorePanel.add (new JLabel ("Score:"));
- scorePanel.add (Box.createVerticalStrut (220));
- pane.add (scorePanel);
- // pane.addActionListener (this);
- pane2.add (pane);
- }
- public static void main (String [] args) {
- BoxLayoutTest test = new BoxLayoutTest();
- test.setVisible (true);
- }
- public void actionPerformed (ActionEvent evt) {
- System.out.println (evt.getActionCommand());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement