• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with GridBagLayout Manager while adding any component  RSS feed

 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to set a JPanel with GridBagLayout and whenever I am trying to add any component in that JPanel , the component is being displayed in the Center Only. If I remove the layout , then the scenario is fine.


 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My advice is to learn the other layout managers first before attempting to learn how to use the GridBagLayout. Any class that requires you to learn how to set the value of multiple constraints will be more difficult to learn than those that require 0 or 1 one constraint.

Read the section from the Swing tutorial on How to Use GrigBagLayout, which explains the usage of each of the constraints. I think its the weightX/Y that is the problem.
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I appreciate your advice but for my project I need to use the GridBagLayout Manager only.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search Cai Horstmann's website or his book for help with GridBag.
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
buntha Choudhary wrote:I appreciate your advice but for my project I need to use the GridBagLayout Manager only.


What project, you mean for your school assignment?

Otherwise there is no reason to be forced to use a specific layout manager. That is why multiple layout managers exists. You use the appropriate combination of layout managers to get the desired effect.
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No School Project, Its the problem with Company Project .

My Managers are just forcing me to use only GridBagLayout , why , even I dont know
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post a link to an image that demonstrates what you are trying to accomplish here, what you want your current small app to look like when it's through? Either that or describe the desired result in as much detail as possible.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Application is very big so I only added a dummy piece of code and now I need to make a form for adding Reminder. I have solved the issue with BorderLayout but problem is , according to the SRS , I need to follow GridBagLayout.

In that form , I need to paste first a Subject Field (1 Row), then Time and Date (Next Line) , then a Combo Box with name and Image(this should cover atleast 5 rows) , then in next line will add a text area for Description(5 rows) , then again after the Text Area , will add Importancy as Combo Box(1 Row) and finally in the end of the Panel , will add a Button for Saving all the above entered records.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!