Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GridLayout GUI question  RSS feed

 
jesal dosa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I hope so one can help.

I am using the GridLayout to split my panel into 3 rows and 2 columns



Now I use the



this add components in 1,1 1,2 2,1 ,2,2 ... in this order

To add my component to the panel. I want to do is add a component in the following place (row,column) 1,1 2,1 2,2 3,1

Is there a way to do this?

Or do i need to another layout if so which one, i was thinking i could split the panel, but then i would still have problems adding this in the order i require
 
Alecsandru Cocarla
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out GridbagConstraints, and maybe also SUN's Swing tutorial, the layout managers section.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GridBagConstraints are meant for GridBagLayout and not GridLayout.

Just change the sequence in which you are adding your components to the panel to get the desired result.
And remember, the index starts with 0 and not 1

Swing related.
Moving.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want an invisible component, you could try adding a text-less label in the empty cells.
If you do want some component there, you'll have no choice but to rearrange your adding statements.
 
Alecsandru Cocarla
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, sorry about my mistake, I read GridBagLayout... Anyway, you could probably consider using the GridBagLayout in this case.
 
Campbell Ritchie
Sheriff
Posts: 53760
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an alternative to GridBag, try googling for MigLayout; a lot of people think that is better, but I have never tried it myself.
 
jesal dosa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do you mean change the sequence in which i use the add statements? Ill go with robs idea, i want a invisible panel, so ill just add a text less label, that should do the trick

Thanks for all the help, its been a long time since someones actually replied to my post, usually i get left to reply back to my own posts
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jesal dosa wrote:Thanks for all the help, its been a long time since someones actually replied to my post, usually i get left to reply back to my own posts

If that happens, it usually just means that nobody has a good answer for you. We're definitely not ignoring you on purpose
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get the most of the Ranch, you need to post in the proper forum. I just looked at your posts, and all of them are in the SCJD, except this one, which I moved.

 
K. Tsang
Bartender
Posts: 3624
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of using GridBagLayout, have you try using a dummy JPanel in your so-called 1-2 grid position?

Or if possible you can make your 1-1 component to span 2 columns.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!