Results 1 to 7 of 7
- 07-27-2009, 07:33 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 13
- Rep Power
- 0
-
In what context? Swing? AWT? SWT? None of the above?
- 07-27-2009, 10:42 PM #3
Member
- Join Date
- Sep 2008
- Posts
- 13
- Rep Power
- 0
Well I came up with a solution using swing, I used a key listener on my main JApplet class but it doesn't detect any keystrokes until i click on the window of the app. I always have to click on the already focused window. And it turns out that my previous solution wasn't using a listener but a dispatcher, so that explained the keystroke-like registering.
-
Have you looked at using key bindings? These can work even if the component that has the binding doesn't have focus but is held by the window with focus.
- 07-27-2009, 11:07 PM #5
Member
- Join Date
- Sep 2008
- Posts
- 13
- Rep Power
- 0
Not at all, how would I do that using my JApplet or Jframe class?
-
Here's an example program that shows use of key bindings. In this program pressing one of the arrow keys together with alt will start a Swing Timer that will keep firing (appending a String in a JTextArea) until the alt-arrow key has been released.
I'm no expert in key binding, so please take this program as only a suggestion for ideas, not as gospel. Also, since for unknown reasons the forum doesn't allow posting of code with key binding in it, I created a Jar file with source code and then changed the extension to zip and uploaded it. Please let me know if I can answer any questions about this.
Best of luck
- 07-28-2009, 01:32 AM #7
Member
- Join Date
- Sep 2008
- Posts
- 13
- Rep Power
- 0
Well I already came up with a sugerpacket solution by creating a keylistener and adding that single listener to JApplet and JFrame. It works, well I'd say.
As for the example, how exactly do you perform the example? I looked at the code and it looks like a timer's suppose to trigger or something causing some text to appear in one of the edit controls? I'm not sure.
Similar Threads
-
It simply won't sort
By xf021209 in forum New To JavaReplies: 7Last Post: 04-25-2009, 03:53 PM -
input to an integer (simply)
By chitwood in forum Advanced JavaReplies: 3Last Post: 03-18-2009, 06:34 AM -
Addin color to text, probs really simply, please help!!!
By soc86 in forum New To JavaReplies: 6Last Post: 10-17-2008, 06:11 PM -
Error With Simply Displaying Picture
By JDCAce in forum Java AppletsReplies: 4Last Post: 10-07-2008, 08:09 PM -
Simply output the result to a text file.
By silvia in forum New To JavaReplies: 1Last Post: 08-07-2007, 05:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks