Name: jk109818 Date: 03/05/2002 FULL PRODUCT VERSION : "java version "1.4.0-rc Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-rc-b91) Java HotSpot(TM) Client VM (build 1.4.0-rc-b91, mixed mode) FULL OPERATING SYSTEM VERSION : Windows 98 [Version 4.10.2222] A DESCRIPTION OF THE PROBLEM : although the addKeyListener is written in the main frame and also in the internalframe, it's not working after internalframe got focus by the mouse, and not after it lost focus again and the main frame got beck the focus. REGRESSION. Last worked in version 1.3.1 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1.after the program is running I press Esc... it's working for now 2.now I press on the internalframe with the mouse and try to press the Esc again... not working 3.now I press on the main frame again with the mouse and try to press the Esc again... not working EXPECTED VERSUS ACTUAL BEHAVIOR : I saw in the erlier versions that only 1 addKeyListener in the main frame was enough to catch the keyEvent in the program but now even after puting 2 listeners 1. in the main frame. 2. in the internal frame it's not enough. This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class mainDiamond extends JFrame { JDesktopPane desk; Vector popups = new Vector(); Dimension size; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); public mainDiamond() { super("Community"); mainDiamond mD = this; setSize(800, 600); size = getSize(); screenSize.height = screenSize.height/2; screenSize.width = screenSize.width/2; size.height = size.height/2; size.width = size.width/2; int y = screenSize.height - size.height; int x = screenSize.width - size.width; setLocation(x, y); this.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { int code = keyEvent.getKeyCode(); if(code==27) try { System.out.println("ESC"); } catch(Exception ioe){} } }); desk = new JDesktopPane(); getContentPane().add("Center", desk); intframe Rframe = new intframe(mD); AddInternalFrame(Rframe,1); } public void AddInternalFrame(JInternalFrame jif,int i) { popups.addElement(jif); desk.add(jif, new Integer(i)); // Keep sites on top for now try { jif.setSelected(true); } catch (java.beans.PropertyVetoException e2) {} jif.show(); } public static void main(String args[]) { mainDiamond main = new mainDiamond(); //main.diamond(); main.setVisible(true); } } class intframe extends JInternalFrame{ public mainDiamond mD; public intframe pl; public intframe(mainDiamond MD) { setBounds(100,100,300,300); setClosable(true); setMaximizable(false); setIconifiable(false); setResizable(false); mD = MD; setTitle("Suppliers administrator"); addInternalFrameListener(new MyInternalFrameListener()); JDesktopPane desk = new JDesktopPane(); desk.add(this,JDesktopPane.PALETTE_LAYER); this.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent keyEvent) { int code = keyEvent.getKeyCode(); if(code==27) try { System.out.println("ESC"); } catch(Exception ioe){} } }); } class MyInternalFrameListener extends InternalFrameAdapter { public void internalFrameClosing(InternalFrameEvent event) { } } } ---------- END SOURCE ---------- Release Regression From : 1.3.1 The above release value was the last known release where this bug was known to work. Since then there has been a regression. (Review ID: 139023) ======================================================================
|