Results 1 to 2 of 2
- 07-25-2007, 05:03 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 44
- Rep Power
- 0
Help with import AWTKeyStroke and swing.KeyStroke
What do you need to import to instantiate a newly KeyStroke object? Here's the code I have:
When I compile the program I get.Java Code:import java.awt.AWTKeyStroke; import javax.swing.KeyStroke; ... KeyStroke k = new KeyStroke(); ... System.out.println("Type something: "); key = k.getKeyStroke(); System.out.println("The key you pressed was: "+key+".\n"); ...
Thanks.Java Code:--------------------Configuration: <Default>-------------------- C:\Documents and Settings\admin\Desktop\KeyLogger.java:19: cannot resolve symbol symbol : constructor KeyStroke () location: class javax.swing.KeyStroke KeyStroke k = new KeyStroke(); ^ C:\Documents and Settings\admin\Desktop\KeyLogger.java:26: cannot resolve symbol symbol : method getKeyStroke () location: class javax.swing.KeyStroke key = k.getKeyStroke();
- 07-29-2007, 10:53 PM #2
The compiler is telling you it cannot find a no–argument Keystroke constructor.cannot resolve symbol
symbol : constructor KeyStroke ()
location: class javax.swing.KeyStroke
KeyStroke k = new KeyStroke();
Look in the KetStroke class api. There are no constructors. All KeyStroke instances are obtained from the static methods.
Java Code:KeyStroke k = KeyStroke.getKeyStroke(5 possible args);
Same thing: can't find a method getKeyStroke called on a KeyStroke instance. Check the api. A KeyStroke instance is already a KeyStroke.cannot resolve symbol
symbol : method getKeyStroke ()
location: class javax.swing.KeyStroke
key = k.getKeyStroke();
Java Code:KeyStroke keyStroke = KeyStroke.getKeyStroke("UP");
Similar Threads
-
how to import a picture into an applet
By cecily in forum Java AppletsReplies: 2Last Post: 01-15-2010, 08:51 PM -
how to read single Keystroke without using return
By oomanamemni in forum New To JavaReplies: 1Last Post: 02-14-2008, 07:21 PM -
import statement.
By diRisig in forum New To JavaReplies: 2Last Post: 02-08-2008, 12:34 AM -
how to import jface in java swt
By rajaletchumy in forum New To JavaReplies: 1Last Post: 08-08-2007, 12:31 AM -
I can't import javax.mail
By katie in forum New To JavaReplies: 2Last Post: 08-04-2007, 05:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks