• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting Dimensions (Screen Size)dynamically  RSS feed

 
Murali Jaya Rao
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

My requirement is, based on the screen size(resolution)components should be aligned properly.Presently I have used GridBagLayout manager to arrange components wherever i need in the frame.But when i minimized or maximized the components are not aligned properly.

so,i want to get resolution of the screen(frame size) at runtime.based on the resolution i can arrange components correctly.

can anyone give me suggestions for this.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get the screen size easily enough via the Toolkit class, but your post suggests to me that you really don't need this information, that instead you just need to know how to better use the layout managers. For one thing, GridBagLayout is one of the more difficult ones to use correctly. Are you sure that you need it, that your needs won't be better served by nesting JPanels each using a different layout?

If this doesn't help you, you may wish to post a small compilable program that demonstrates your problem, either that or post a link to a screen photo your app as you don't want it and as you desire it to be.
 
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
Originally posted by Murali Jaya Rao:
...I have used GridBagLayout manager .. components are not aligned properly.


I dont think you are using the GridBagLayout properly then.
One of the good things about this layout, is you can force the components to stay anchored at some location (e.g. top left) so that, even when the parent frame is resized, the components do not leave this anchor position.
(To clarify this "anchoring", think FlowLayout, where the components leave their "anchor" when the frame is resized)

Like Pete has said, post your relevant code, which we can compile and run and will demonstrate the exact problem you are facing.
 
Murali Jaya Rao
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your valuable suggestions,now i am able to use Gridbag Layout more conveniently. As peter said, it is one of the toughest layout but it is very needful/helpful than any other layouts.

Once again thanks for suggestions.

Thanks,
Murali.
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I shall quote you the standard aid to getting GridBag to work (Cai Horstmann's GBC class) and the standard aid to not getting GridBag to work (here ).
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!