Click to See Complete Forum and Search --> : keyboard input?[Resolved]
quipy
May 28th, 2003, 08:58 AM
i've always used the non-standard Keyboard class. what is the standard way to get input from the keyboard? and how do you get its "type"? (like readInt, readString from the Keyboard class)
Dillinger4
May 28th, 2003, 01:39 PM
class X{
JTextField() Jtf = new JTextField();
jtf.addKeyListener(new Keyboard());
}
class B extends KeyAdapter{
public void keyPressed(KeyEvent ke){
if(Character.isDigit(ke.getKeyChar())){
int type = Character.getType(ke.getKeyChar());
// ........
}else if(Character.isLetter(ke.getKeyChar())) {
// .............
}
}
}
quipy
May 28th, 2003, 11:08 PM
what about for normal, non-user interface (command line) input?
Dillinger4
May 28th, 2003, 11:12 PM
The arguments must be passed in when the program i run. ie
C:\ java -classpath C:\Java; X arg1 arg2...........
class X{
public static void main(String[] args){
for(int i = 0; i < args.length; ++i){
System.out.println(args[i]);
}
}
}
quipy
May 28th, 2003, 11:19 PM
what?! :confused:
Dillinger4
May 28th, 2003, 11:21 PM
Or if you want.
import java.io.*;
public class Q{
public static void main(String[] args){
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
try{
String s = buff.readLine();
System.out.println(s);
}catch(IOException e){;}
}
}
Dillinger4
May 28th, 2003, 11:22 PM
Posted by quipy
what?! :confused:
What don't you understand? Ill be more then happy to explain. :)
quipy
May 28th, 2003, 11:25 PM
is
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
the easiest way to achieve this? man, no wonder some guy wrote that Keyboard class...
Is this correct:
System.out.println("Please enter name: ");
System.in;
Dillinger4
May 28th, 2003, 11:31 PM
That would not be a statement. :p System.in
quipy
May 28th, 2003, 11:36 PM
okay got that, thanks :)
could you possibly help me out in my windows thread? :(
Dillinger4
May 28th, 2003, 11:40 PM
I took a quick look at it but ill have to tacke that tommorow afternoon. I have an economics exam at 9am tommorow. :( Still gota study. :D
Maybe someone else will get to it before me. Perhaps CornedBee or crptcblade.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.