Results 1 to 2 of 2
  1. #1
    desoky725 is offline Member
    Join Date
    Sep 2011
    Posts
    5
    Rep Power
    0

    Default problem with key events

    I've just started programming with java netbeans, I made a simple program that get a copied url from clipboard and open it with IE or Firefox.
    the problem is about key Events , when I open the software it by default make a dotted square on the first button , so when i press for example "ctrl+F2" it open IE,but when i press "ctrl+F3" it doesnot open firefox.
    Can I write a general function for key Events in netbeans that is valid weather this button is activated or the other one is.
    problem with key events-java.png
    Java Code:
    private void ieKeyPressed(java.awt.event.KeyEvent evt) {                              
        // TODO add your handling code here:
            if(evt.isControlDown()){
                if(evt.getKeyCode()== KeyEvent.VK_F2)
                    ie.doClick();
        }   
    }                          
        
    private void fxKeyPressed(java.awt.event.KeyEvent evt) {                              
        // TODO add your handling code here:
             if(evt.isControlDown()){
                if(evt.getKeyCode()== KeyEvent.VK_F3)
                   fx.doClick();
        }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default Re: problem with key events

    Assuming those are JButtons then you want setMnemonic(), instead of faffing with key events.

Similar Threads

  1. Key Events
    By rdjava in forum Java Gaming
    Replies: 0
    Last Post: 04-15-2011, 08:02 AM
  2. typed events vs untyped events.
    By Drun in forum SWT / JFace
    Replies: 0
    Last Post: 11-23-2009, 12:22 PM
  3. Need Help with events
    By Gatts79 in forum AWT / Swing
    Replies: 3
    Last Post: 09-23-2008, 03:18 AM
  4. swing events
    By chitra in forum AWT / Swing
    Replies: 3
    Last Post: 09-20-2008, 04:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •