Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Name: rmT116609 Date: 06/13/2003 FULL PRODUCT VERSION : java version "1.4.2-beta" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19) Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode) FULL OS VERSION : Microsoft Windows XP [verzi^?sz��m: 5.1.2600] A DESCRIPTION OF THE PROBLEM : The keyboard focus disappeard with the closed internal frame. See the test code. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Execute the attached test code. 1. Selected the Internal frame(click on the header of it or ...) 2. Selected the Menu/Close menuitem, which close the internal frame 3. The keyboard focus has been lost. Check the debug lines on the output where is the focus. ACTUAL - The keyboard focus has been disappeard with closed internal frame. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- /* * FocusTest.java * * Created on 2003. jM-^Tnius 13., 12:38 */ package TEST; import java.awt.Component; import java.awt.KeyboardFocusManager; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JInternalFrame; import javax.swing.JPanel; import javax.swing.Timer; public class FocusTest extends javax.swing.JFrame { private JInternalFrame jInternalFrame1; /** Creates new form FocusTest */ public FocusTest() { initComponents(); jInternalFrame1 = new JInternalFrame(); jInternalFrame1.setVisible(true); jInternalFrame1.setBounds(0, 0, 270, 240); jInternalFrame1.getContentPane().addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { System.out.println("contentpane of internal frame GAINED the focus"); } public void focusLost(FocusEvent e) { System.out.println("contentpane of internal frame LOST the focus"); } }); jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER); Timer timer = new Timer(1500, new ActionListener() { public void actionPerformed(ActionEvent e) { Component comp = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); if (comp == null) System.out.println("Focus on NULL"); else { Component temp = comp.getParent(); while (temp != null && !(temp instanceof JInternalFrame) && !(temp instanceof JFrame)) temp = temp.getParent(); System.out.println("Focus on "+comp.getClass()+" Parent: "+(temp == null ? "null" : temp.getClass().toString())); } } }); timer.start(); setSize(400, 300); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() { jDesktopPane1 = new javax.swing.JDesktopPane(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } }); getContentPane().add(jDesktopPane1, java.awt.BorderLayout.CENTER); jMenu1.setText("Menu"); jMenuItem1.setText("Close frame"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu1.add(jMenuItem1); jMenuBar1.add(jMenu1); setJMenuBar(jMenuBar1); pack(); } private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { // Add your handling code here: jInternalFrame1.setVisible(false); jInternalFrame1.dispose(); jInternalFrame1 = null; System.out.println("ClosED the internal frame"); } /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) { System.exit(0); } /** * @param args the command line arguments */ public static void main(String args[]) { new FocusTest().show(); } // Variables declaration - do not modify private javax.swing.JDesktopPane jDesktopPane1; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenu jMenu1; // End of variables declaration } ---------- END SOURCE ---------- (Review ID: 187979) ======================================================================
|