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.
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.
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.