Modified the way the controlled panel is monitored. It should work
the same as before, but will count as being displayed even if in a non-showing tab. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1434 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Controller.java,v 1.17 2004/01/16 15:25:29 mdb Exp $
|
// $Id: Controller.java,v 1.18 2004/05/21 20:53:08 ray Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -29,10 +29,11 @@ import java.lang.reflect.Method;
|
|||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.event.AncestorEvent;
|
|
||||||
|
import java.awt.event.HierarchyEvent;
|
||||||
|
import java.awt.event.HierarchyListener;
|
||||||
|
|
||||||
import com.samskivert.Log;
|
import com.samskivert.Log;
|
||||||
import com.samskivert.swing.event.AncestorAdapter;
|
|
||||||
import com.samskivert.swing.event.CommandEvent;
|
import com.samskivert.swing.event.CommandEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,15 +104,25 @@ public abstract class Controller
|
|||||||
/**
|
/**
|
||||||
* Lets this controller know about the panel that it is controlling.
|
* Lets this controller know about the panel that it is controlling.
|
||||||
*/
|
*/
|
||||||
public void setControlledPanel (JComponent panel)
|
public void setControlledPanel (final JComponent panel)
|
||||||
{
|
{
|
||||||
panel.addAncestorListener(new AncestorAdapter() {
|
panel.addHierarchyListener(new HierarchyListener() {
|
||||||
public void ancestorAdded (AncestorEvent event) {
|
public void hierarchyChanged (HierarchyEvent e) {
|
||||||
wasAdded();
|
boolean nowShowing = panel.isDisplayable();
|
||||||
}
|
//System.err.println("Controller." + Controller.this +
|
||||||
public void ancestorRemoved (AncestorEvent event) {
|
// " nowShowing=" + nowShowing +
|
||||||
wasRemoved();
|
// ", wasShowing=" + _showing);
|
||||||
|
if (_showing != nowShowing) {
|
||||||
|
_showing = nowShowing;
|
||||||
|
if (_showing) {
|
||||||
|
wasAdded();
|
||||||
|
} else {
|
||||||
|
wasRemoved();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean _showing = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user