• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting Dimensions (Screen Size)dynamically

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ).
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic