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)
Printable View
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)
Code:class X{
JTextField() Jtf = new JTextField();
jtf.addKeyListener(new Keyboard());
}
Code: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())) {
// .............
}
}
}
what about for normal, non-user interface (command line) input?
The arguments must be passed in when the program i run. ie
C:\ java -classpath C:\Java; X arg1 arg2...........
Code:class X{
public static void main(String[] args){
for(int i = 0; i < args.length; ++i){
System.out.println(args[i]);
}
}
}
what?! :confused:
Or if you want.
Code: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){;}
}
}
What don't you understand? Ill be more then happy to explain. :)Quote:
Posted by quipy
what?! :confused:
is
the easiest way to achieve this? man, no wonder some guy wrote that Keyboard class...Quote:
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
Is this correct:
System.out.println("Please enter name: ");
System.in;
That would not be a statement. :p System.in
okay got that, thanks :)
could you possibly help me out in my windows thread? :(
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.