Results 1 to 5 of 5
Thread: JScrollPane keyevents
- 03-24-2012, 05:28 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 39
- Rep Power
- 0
- 03-24-2012, 06:21 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: JScrollPane keyevents
I would consume the key event if I don't want it to bubble up. Let say if I have a JTextArea and I add it into a container like JScrollPane. I will have some thing like the following key listener in my JTextArea.
Java Code:... if (e.getKeyCode() == KeyEvent.VK_UP) { e.consume(); } ...Website: Learn Java by Examples
- 03-24-2012, 07:12 AM #3
Member
- Join Date
- Feb 2012
- Posts
- 39
- Rep Power
- 0
Re: JScrollPane keyevents
Ok, thanks im sure it will work, but hoping there was a simple way.
- 03-24-2012, 07:17 AM #4
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: JScrollPane keyevents
You could also use an InputMap of the component to disable some keys.
Java Code:InputMap map = textArea.getInputMap(); map.put(KeyStroke.getKeyStroke("UP"), "none");Website: Learn Java by Examples
- 03-27-2012, 03:09 AM #5
Similar Threads
-
JFrames and KeyEvents
By CuddlyKittens11 in forum AWT / SwingReplies: 1Last Post: 05-05-2011, 12:58 AM -
Question on Graphics/JFrame/KeyEvents
By loopsnhoops in forum New To JavaReplies: 4Last Post: 02-10-2011, 11:22 PM -
Getting keyEvents even though the program is not in focus
By Skurken in forum Advanced JavaReplies: 3Last Post: 02-02-2011, 10:53 AM -
Automatic convert to uppercase in keyevents
By ashin in forum SWT / JFaceReplies: 4Last Post: 08-09-2010, 01:59 PM -
Question about java keyevents?
By Godsent in forum AWT / SwingReplies: 2Last Post: 10-26-2009, 09:38 PM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks