-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
1.3.1, 1.4.0
-
sparc
-
solaris_2.6, solaris_7
There is a tremendous need for setState method to work with JWindow (similar
to the way it works for JFrame). This method is needed to deiconify a JWindow
programatically, when it is observed to be iconified.
This can be accomplished by probably moving setState method up the hierarchy
to java.awt.Window class OR somehow giving setState API functionality to
work with JWindow.
JWindow is used in this production application not to have the WM decorations,
for various reasons. This application (like a CDE front panel), acts as a
control center, launching other applications. This application needs to appear
as being part of the screen, as something that controls the entire desktop.
This application needs to be visible and at a set location at all times
(and cannot give the appearance that it can be moved, iconified, maximized,
etc). Unfortunately, users still can use dtwm modifiers (Alt-F7, Alt-F9, etc)
to move, iconify, etc JWindow based GUI. There is a need to negate these users'
behavior, but unfortunately lack of setState method for JWindow prevents
un-doing inconify from an user.
Unfortunately this functionality is not available in jdk 1.3.1 and in jdk 1.4 beta.
The following code tested with jdk 1.3.1 and jdk 1.4 beta exhibits this request,
in much detail.
We used java.awt.Frame.setUndecorated(true), as mentioned (commented out) in the
supplied sample code (new feature in jdk 1.4 beta). But unfortunatley, we
encountered other problems (in process of filing bug reports w.r.t. jdk 1.4 beta).
Code Examples:
A. TestIconifyMoveFrame.java
This code example uses a JFrame and shows the correct (expected) behaviors:
1. Moving the JFrame (pressing Alt-F7 with frame in focus, moving mouse to
new location and clicking to complete move) generates a ComponentEvent and
calls the componentMoved() method.
2. setLocation method called from within the code works consistently.
B. TestIconifyMoveWindow.java
This code example uses a JWindow and does NOT exhibit the correct
(expected) behaviors:
1. Moving the JWindow (pressing Alt-F7 with window in focus, moving mouse
to new location and clicking to complete move) does NOT generate a
ComponentEvent!
2. setLocation() method does not work consistently, when called within
the code (or if it where to be called from the ComponentEvent handler).
TestIconifyMoveFrame.java
==========================
import java.awt.Point;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class TestIconifyMoveFrame extends JFrame
{
public static void main(String[] args)
{
final Point p = new Point(0, 0);
final JFrame f = new JFrame("Test Frame");
f.addComponentListener(new ComponentAdapter()
{
public void componentMoved(ComponentEvent e)
{
System.out.println("Component moved to " +
f.getLocation());
System.out.println("Moving component to " +
p);
f.setLocation(p);
System.out.println("Component now located at " +
f.getLocation());
} // end componentMoved()
} // end inner class
);
f.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(1);
} // end windowClosing()
public void windowIconified(WindowEvent e)
{
System.out.println("Window iconified. Attempting to deiconify.");
f.setState(JFrame.NORMAL);
f.show();
System.out.println("Window deiconified.");
} // end windowIconified()
} // end inner class
);
// setUndecorated is a new feature in jdk 1.4 beta
// f.setUndecorated(true);
f.setSize(50, 50);
f.show();
System.out.println("Init: moving component to " +
p);
f.setLocation(p);
System.out.println("Init: component now located at " +
f.getLocation());
} // end main()
} // end TestIconifyMoveFrame
TestIconifyMoveWindow.java
==========================
import java.awt.Point;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JWindow;
public class TestIconifyMoveWindow extends JWindow
{
public static void main(String[] args)
{
final Point p = new Point(0, 0);
final JWindow w = new JWindow();
w.addComponentListener(new ComponentAdapter()
{
public void componentMoved(ComponentEvent e)
{
System.out.println("Component moved to " +
w.getLocation());
System.out.println("Moving component to " +
p);
w.setLocation(p);
System.out.println("Component now located at " +
w.getLocation());
} // end componentMoved()
} // end inner class
);
w.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(1);
} // end windowClosing()
public void windowIconified(WindowEvent e)
{
System.out.println("Window iconified. Attempting to deiconify.");
// NO METHOD EXISTS IN JWINDOW TO DO THIS!!!
// w.setState(JFrame.ICONIFIED);
w.show();
System.out.println("Window deiconified.");
} // end windowIconified()
} // end inner class
);
w.setSize(50, 50);
w.show();
System.out.println("Init: moving component to " +
p);
w.setLocation(p);
System.out.println("Init: component now located at " +
w.getLocation());
} // end main()
} // end TestIconifyMoveWindow
- relates to
-
JDK-4479617 Moving an undecorated JFrame does not generate corresponding events
- Open
-
JDK-4478302 Moving a JWindow does not generate corresponding event AND prob w/ setLocation
- Resolved
-
JDK-4477023 Moving a JWindow does not generate a corresponding event
- Closed