-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.3.0
-
x86
-
windows_nt
Name: krT82822 Date: 11/18/99
11/18/99 eval1127@eng -- believe this is a dupe, but can't find existing bug (may be related to 4285225).
java version "1.2.2" (problem still exists as of 1.3 RA -- meaning, 1.3.0 build "I")
HotSpot VM (1.0.1, mixed mode, build g)
I want a JInternalFrame to do something if the user presses a function key
(i.e. F5) while that Frame has got the focus. Well, I thought the most obvious
way to do this is to simply add an KeyAdapter to the JInternalFrame's
(inherited) addKeyListener() method.
But the keyPressed/Released/Typed methods never get called!
################################################################
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class SampleDesktop extends JFrame
{
protected JDesktopPane mDesktopPane;
public SampleDesktop(String aTitle)
{
super(aTitle);
mDesktopPane = new JDesktopPane();
setContentPane(mDesktopPane);
createInternalFrame();
}
protected void createInternalFrame()
{
JInternalFrame lIFrame = new JInternalFrame("JInternalFrame",true, true, true, true);
lIFrame.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent ev)
{
JOptionPane.showInternalMessageDialog(mDesktopPane, "keyPressed!", "information", JOptionPane.INFORMATION_MESSAGE);
}
public void keyReleased(KeyEvent ev)
{
JOptionPane.showInternalMessageDialog(mDesktopPane, "keyReleased!", "information", JOptionPane.INFORMATION_MESSAGE);
}
public void keyTyped(KeyEvent ev)
{
JOptionPane.showInternalMessageDialog(mDesktopPane, "keyTyped!", "information", JOptionPane.INFORMATION_MESSAGE);
}
});
mDesktopPane.add(lIFrame, JDesktopPane.DEFAULT_LAYER);
lIFrame.setSize(200, 200);
lIFrame.show();
}
public static void main(String[] args)
{
SampleDesktop myDesktop = new SampleDesktop("JInternalFrameTest");
myDesktop.setSize(300,300);
myDesktop.setVisible(true);
}
}
################################################################
(Review ID: 97515)
======================================================================