-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
5.0
-
x86
-
linux
If container contains several focusable components, focus owner is in
this container and we remove this container than autotransfer moves focus
to next component in the container and thus focus stuck on it.
Here is a testcase:
import javax.swing.*;
import java.awt.event.*;
class AcceleratorKeyProblem {
public static void main( String[] args ) {
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
JMenuItem quit = new JMenuItem();
quit.setAction( new AbstractAction( "Quit" ) {
public void actionPerformed( ActionEvent _ ) {
frame.dispose();
}
} );
quit.setAccelerator( KeyStroke.getKeyStroke( "control Q" ) );
JMenu menu = new JMenu( "File" );
menu.add( quit );
JMenuBar menuBar = new JMenuBar();
menuBar.add( menu );
frame.setJMenuBar( menuBar );
final JPanel mainPanel = new JPanel();
final JPanel panel1 = new JPanel();
final JPanel panel2 = new JPanel();
JButton b1 = new JButton( "b1" );
JButton b2 = new JButton( new AbstractAction( "b2" ) {
public void actionPerformed( ActionEvent _ ) {
mainPanel.remove( panel1 );
mainPanel.add( panel2 );
mainPanel.revalidate();
}
} );
panel1.add( b1 );
panel1.add( b2 );
panel2.add( new JButton( "b3" ) );
mainPanel.add( panel1 );
frame.getContentPane().add( mainPanel );
frame.getRootPane().setDefaultButton( b2 );
frame.pack();
frame.setVisible( true );
}
}
Steps to reproduce:
start the test, click on b2 button (it removes panel with b1 and b2 and adds
panel with b3). After that focus will be on b1 (which was removed).
I've tested this on Linux.
###@###.### 2005-1-14 11:16:30 GMT
- relates to
-
JDK-6180261 Focus error when disabling in focus JTextField from TreeSelectionListener
- Closed
-
JDK-4726458 Dialogs and Frames are never garbage collected
- Closed
-
JDK-4781423 Alt Key Errors and NullPointerException After Removal of Container with Focus
- Closed
-
JDK-6247376 Not able to navigate using keyboard for particular scenario in JavaApplicationCacheViewer
- Closed
-
JDK-6469530 Memory leak in the focus subsystem
- Closed
-
JDK-4732067 Problems when requesting focus on component and hiding it at once
- Closed
-
JDK-6321947 GC does not complete after Frame.dispose() until focus/unfocus of another Frame
- Closed