Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set Layout ?  RSS feed

 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Members,

This is my code for designing a simple window . In this I used GridLayout (some other also).But fail to fix it .Here I used the same thing in above panel but I do not know that why is it not working in the second panel ?

Here is my code




Thanks In Advance !!

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Maneesh,

For early reply ! I am new to swing.I already visited this link but no success.



My problem is that the same thing I am
doing while creating the above panel . It is running fine but the middle panel not . I do not know where am I wrong?



 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try smaller applications and put them together bit by bit to create a larger application.
 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Try smaller applications and put them together bit by bit to create a larger application.


Thanks ,
Ok Let me try !

 
Alan Mehio
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You have three internal panel which are using a GridLayout manager and you decided how many rows and columns and the gaps in the first and second panel.
So the layout will have a grid of same size; please refer to javadoc for GridLayout manager,
You should not add contraint which is related to the gridbagLayout when adding the component to the first panel as you did here

referToPnl.add(lbl, cnstrt)

remove it and into

referToPnl.add(lbl) // no constain since the GridLayout will lay it as you defined in the contstructor i.e new GridLayout(2, 10, 2, 2)

Then there is a line which is

referToPnl.add(refDocName, BorderLayout.LINE_START);

you are saying the panel is using a GridLayout and you send a BorderLayout Constraint which you should not do that. ( Do you think it is a Microsoft prodcut which does things correctly even you do it incorrectly)

please remove it to
referToPnl.add(refDocName)


So remove all the constrains when you add to the panels which have GridLayout manager


Let us know the result


 
Fidel Edwards
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Alan !
Well I followed Campbell Ritchie & your suggestion slowly and consistently. I achieved the goal.

Alan Mehio wrote:

you are saying the panel is using a GridLayout and you send a BorderLayout Constraint which you should not do that. ( Do you think it is a Microsoft prodcut which does things correctly even you do it incorrectly)




I liked that comment but It may hurt any Microsoft loving guy !!


Thanks for patience and solution !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!