Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

addKeyListener in JInternalFrame?

Thread view: 
Ron - 22 Nov 2005 04:20 GMT
The following code does not seem to work:

public class DocumentSetupDialog extends JInternalFrame {
    public DocumentSetupDialog {
         addKeyListener(new KeyAdapter() {
              public void keyPressed(KeyEvent e) {
                   System.out.println("hello");
              }
         });
    }
}

Neither does getGlassPane().addKeyListener()

How do I pick up key events in JInternalFrames?

Thanks,
Ron
zero - 22 Nov 2005 20:25 GMT
"Ron" <roninabox@gmail.com> wrote in news:1132633221.618643.56110
@g43g2000cwa.googlegroups.com:

> The following code does not seem to work:
>
[quoted text clipped - 14 lines]
> Thanks,
> Ron

I haven't tried this, but I read somewhere that you should add the
KeyListener to the DesktopPane, and in the keyPressed method use
getSelectedFrame to see which JInternalFrame has the focus.
Ron - 23 Nov 2005 13:25 GMT
You know, this isn't working for a JDialog either.
Michael Dunn - 23 Nov 2005 18:24 GMT
> The following code does not seem to work:
>
[quoted text clipped - 14 lines]
> Thanks,
> Ron

add this line

public DocumentSetupDialog {
     setFocusable(true);//<----------------------------
     addKeyListener(new KeyAdapter() {
Ron - 23 Nov 2005 21:01 GMT
Works. Thanks.

Ron


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.