I believe I don't understand the Window.hide() method. I have both
JFrames and JDialogs that I hide() rather than dispose(), because I will
need them frequently. When hidden, they continue to respond to mouse
events (mouseEntered, for example). It is disconcerting to move the
mouse around in a part of the screen outside the active window and have
lots of mouse events causing unusual behaviors.
Is this the expected behavior of Java? Do I need to remove and reinstall
mouse listeners in all the components in hidden windows?
A program that exhibits this behavior is appended below. It puts up two
windows and tracks mouseEntered events via the console. Clicking either
window hides it, but it continues to respond to mouse events.
Thanks for any help you can provide.
Gary Ford
Plaid Flannel Software
OSX 10.4.4, Java 1.4.2-54
=====
import javax.swing.*;
import java.awt.event.*;
public class HideFrameTest
{
public static void main (String args[])
{
TestFrame f1 = new TestFrame(40, 40, "Left");
TestFrame f2 = new TestFrame(300, 40, "Right");
} // end main()
//====================================
static class TestFrame extends JFrame
{
public TestFrame(int x, int y, String name)
{
setLocation(x, y);
setSize(240, 160);
setName(name);
setDefaultCloseOperation(EXIT_ON_CLOSE);
addMouseListener(new MouseAdapter()
{
public void mouseEntered(MouseEvent pEvent)
{
System.out.println("mouseEntered " + getName());
} // end mouseEntered()
public void mouseClicked(MouseEvent pEvent)
{
System.out.println("mouseClicked " + getName());
((TestFrame)pEvent.getSource()).hide();
} // end mouseEntered()
}
);
show();
} // end constructor
} // end class TestFrame
} // end class HideFrameTest
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden