-
Enhancement
-
Resolution: Fixed
-
P3
-
5.0, 6
-
b14
-
generic, x86
-
generic, windows_xp
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2152908 | OpenJDK6 | Andrei Dmitriev | P2 | Resolved | Fixed | b02 |
I would like to be able to open a frame without it automatically being activated and gaining focus. I can come close to this using the setFocusableWindowState method (see the supplied example code). The example throws an exception (I've included the stack below) because of what appears to be a missing null check in KeyboardManager.registerMenuBar. Commenting out the call to Frame.setJMenuBar in the example code eliminates the exception. In any case this seems to be stretching the intended use of setFocusableWindowState. Perhaps an explicit call along the lines of "showWithoutActivating" could be added.
JUSTIFICATION :
This capability would allow our application to maintain focus in a debugger window, even when user actions in that window (such as single stepping) cause other frames to open
ACTUAL -
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.util.Hashtable.get(Unknown Source)
at javax.swing.KeyboardManager.registerMenuBar(Unknown Source)
at javax.swing.JMenuBar.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at javax.swing.JRootPane.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at java.awt.Window.addNotify(Unknown Source)
at java.awt.Frame.addNotify(Unknown Source)
at java.awt.Window.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at test.ShowNoActivate$1.actionPerformed(ShowNoActivate.java:26)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
CUSTOMER SUBMITTED WORKAROUND :
import java.awt.event.*;
import javax.swing.*;
public class ShowNoActivate {
public static void main(String[] args)
{
final JFrame frame = new JFrame("Show No Activate Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("Create Inactive Frame");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
JFrame inactiveFrame = new JFrame();
inactiveFrame.setJMenuBar(new JMenuBar());
inactiveFrame.setFocusableWindowState(false);
inactiveFrame.addWindowListener(new WindowAdapter() {
public void windowOpened(WindowEvent we) {
frame.toFront();
we.getWindow().setFocusableWindowState(true);
we.getWindow().removeWindowListener(this);
}
});
inactiveFrame.setBounds(frame.getX() + 100, frame.getY(), 300, 300);
inactiveFrame.setVisible(true);
}
});
frame.getContentPane().add(button);
frame.pack();
frame.setVisible(true);
}
}
###@###.### 10/29/04 21:42 GMT
- backported by
-
JDK-2152908 Want to open a Frame without activating it
- Resolved
- duplicates
-
JDK-4963560 Need a way to bring window toFront without focusing
- Closed
- relates to
-
JDK-6567410 PIT : java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusSetVisibleTest.java fails
- Closed
-
JDK-6189501 NullPointerException in KeyboardManager.registerMenuBar()
- Closed
-
JDK-6553134 Swing apps take input focus on launch regardless of window manager policy
- Open
-
JDK-5003401 new window takes focus (overrides window manager policy)
- Open
-
JDK-6399663 window.setVisible(true) is not triggering Gained Focus if a Dialog is dispayed before the window.
- Open
-
JDK-5098172 new JFrame window steals focus instead of letting window manager choose
- Closed
-
JDK-6641929 test/java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusSetVisibleTest.java fails on JDK7b23
- Closed