tags:

views:

44

answers:

1

Hi ..

When I am using GridBagLayout , whenever the window is resized the component locations change to the fit new size ..

Now I want to change the location of a component after an event ( like a mouse click on any button ) until the component goes out of the window (it's like the properties or toolbox window in Visual Studio 2008) , I do that, but when I change the size of th window , this component moves to the last location , which I don't want .

when I put the compoents on the JFrame by GridBagLayout , I used gridx and gridy . What can I use to change this location after creating window ?

+2  A: 

I have no idea what Visual Studio does. But it sounds as if you want to take control of the position of a component away from the layout manager in some circumstance.

To do this, I suggest using layered pane. You panel become a normal layer. On top of that is a glass pane, without a layout manager (or with a specialist one). When you start moving the component remove it from the bottom layer and add it to the glass pane.

A variation is to add all the components to an upper layer. For each component add a proxy component on to a lower layer with the grid bag layout. Usually the proxy updates the location of the real component in response to a change, but allow this to be broken.

Tom Hawtin - tackline
thanks a lot , I will search about it :)
Farah_online
@Farah_online: Here's a good starting point: http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html
trashgod