Results 1 to 7 of 7
Thread: GridLayout question
- 05-14-2012, 11:40 PM #1
Senior Member
- Join Date
- Jan 2012
- Posts
- 142
- Rep Power
- 0
GridLayout question
public class layouttester {
public static void main(String[] args){
JFrame frame = new JFrame();
Container container = frame.getContentPane();
container.setLayout(new GridLayout(10,10));
for(int i =0; i<5; i++)
for(int j=0; j<5; j++)
if(i>=j){
container.add(new JButton("X"));
}
else{ container.add(new JLabel());
}
frame.setSize(500,500);
frame.setVisible(true);
}}
I thought that when we have a gridlayout, it will fill up the rows and then onto the next row etc. Could someone please explain why this one does do so and what difference that for sloop makes.
Thanks you
-
Re: GridLayout question
Please use code tags when posting code here.
Regarding your question, please check out the GridLayout API as it's all spelled out there with the paragraph that begins: "When both the number of rows and the number of columns have been set to non-zero values, either by a constructor or by the setRows and setColumns methods, ..."
- 05-15-2012, 05:40 AM #3
Re: GridLayout question
127 posts and you still don't know how to use code tags? Or is it that you just can't be bothered?
layout question
static question
Quick Question!!!!!!!!
Help with this keyboard GUI
http://www.java-forums.org/forum-mod...tml#post267044
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-09-2012, 03:31 PM #4
Senior Member
- Join Date
- Jan 2012
- Posts
- 142
- Rep Power
- 0
Re: GridLayout question
Sorry, I always forget to use the code tags. From here on in I will always use them. Is what I did above correct?
Thanks
- 12-09-2012, 04:34 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,425
- Blog Entries
- 7
- Rep Power
- 17
Re: GridLayout question
Why do you use a GridLayout(10, 10)?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
-
Re: GridLayout question
@JosAH: check the dates of the question. I think he's trying to make amends for not replying to previous threads, and good for him!
- 12-09-2012, 05:07 PM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,425
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Making a GridLayout?
By umzz in forum AWT / SwingReplies: 1Last Post: 03-19-2012, 10:32 PM -
help! Gridlayout
By eiramae in forum Java AppletsReplies: 3Last Post: 02-19-2011, 05:11 AM -
how to control the GridLayout
By amro in forum New To JavaReplies: 8Last Post: 10-31-2010, 04:45 PM -
SWT GridLayout
By Java Tip in forum Java TipReplies: 0Last Post: 01-08-2008, 09:04 AM -
Gridlayout
By Marty in forum AWT / SwingReplies: 2Last Post: 05-31-2007, 11:48 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks