Results 1 to 2 of 2
Thread: problem with key events
- 09-20-2011, 02:26 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 5
- Rep Power
- 0
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.
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(); }
- 09-20-2011, 02:42 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: problem with key events
Assuming those are JButtons then you want setMnemonic(), instead of faffing with key events.
Similar Threads
-
Key Events
By rdjava in forum Java GamingReplies: 0Last Post: 04-15-2011, 08:02 AM -
typed events vs untyped events.
By Drun in forum SWT / JFaceReplies: 0Last Post: 11-23-2009, 12:22 PM -
Need Help with events
By Gatts79 in forum AWT / SwingReplies: 3Last Post: 09-23-2008, 03:18 AM -
swing events
By chitra in forum AWT / SwingReplies: 3Last Post: 09-20-2008, 04:57 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks