views:

107

answers:

2

Hello

I've got a window and I would like to get notified when the position or the size has changed. Which type of listener ist the best to take?

WindowListener didn't work for me...

Any way?

Thanks and regards

+2  A: 

ComponentListener

camickr
Atmocreations
I'm curious as to why this is better than a ComponentAdapter. I tend to create a derivative and then override the ComponentMoved() and ComponentResized() methods.
clartaq
The question was about which listener to use. People can choose to implement the interface or extend the adapter based on their requirements.
camickr
+1  A: 

You might want to try the HierarchyBoundsListener

     myJFrame.getContentPane().addHierarchyBoundsListener(new HierarchyBoundsListener(){

  public void ancestorMoved(HierarchyEvent e) {
   doSomething();   
  }

  public void ancestorResized(HierarchyEvent e) {
   doSomethingElse();
  }

see http://java.sun.com/docs/books/tutorial/uiswing/events/eventsandcomponents.html for a full list of listeners that all swing components support.

Tedil