• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem with GridBagLayout Manager while adding any component

 
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I appreciate your advice but for my project I need to use the GridBagLayout Manager only.
 
Marshal
Posts: 80279
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Search Cai Horstmann's website or his book for help with GridBag.
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://madbean.com/anim/totallygridbag/
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic