views:

375

answers:

2

We need to place 9 images in a 3 x 3 GridLayout for Java Swing. We tried placing buttons into the grid, which worked fine. The images are on individual Labels. These Labels need to be in the grid, which is not working.

Thanks in advance.

+1  A: 

I had no problems putting 9 labels with images on a panel using the grid layout just now. I'm using NB 6.8.

How is it not working?

Tomislav Nakic-Alfirevic
Thanks for you reply.I'm using NetBeans 6.1 and JDK 1.6 right now. Do you think it could be because I'm using an older version? Should I upgrade my NetBeans?
paul
Nope, works with NB 6.1, too.
Tomislav Nakic-Alfirevic
Thanks again, We are using Windows 7 as our OS. Any compatibility issues/problems for Swing in Netbeans 6.1?Here's a sample code for your kind review - public design1(String design){ super("design1"); p= new JPanel(); l1=new JLabel(); . . l9=new JLabel(); g= new GridLayout(3,3,5,5); icon = new ImageIcon("Capture.JPG"); p.setLayout(g); l1.setIcon(new javax.swing.ImageIcon(getClass().getResource("C:\\Users\\Nihar\\MyDocuments\\NetBeansProjects\\GraphicalPasswords\\src\\graphicalpasswords1\\Capture.JPG"))); Thanks in advance.
paul
+1  A: 

Okay. We got out GridLayout to work finally. Thanks for all your help. FYI, We are now running Netbeans in Windows 7 (on Windows Vista Compatibility mode).

paul
Glad to hear that. :) So it was the switch to Vista Compatibility mode that did it?
Tomislav Nakic-Alfirevic
I think it probably was :)
paul