Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to link a keyboard to the program...

 
Mel Oyello
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I'm part of an AP comp sci class, and my final project is to find a way to link the keyboard to my program...however, I'm not nearly advanced enough to figure out how to use gui's and swing etc...all i'm dealing with is the dos prompt print up...is there anyway to link the keyboard to what a program does without delving into creating your own gui and mastering swing?
thanx dudes
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
look at System.in
 
Kush Kush
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try out following code to take input from Keyboard:
import java.io.*;
class Input{
public static String getInput(){
String result ="";
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
result = br.readLine();
}catch(Exception e){
System.out.println("Error Reading");
}
return (result);
}
}
This is static method on class Input
You can use it as :-
//Your code
String text=Input.getInput();
int i=Integer.parsenInt(Input.getInput());
--- // Your code
[ May 07, 2004: Message edited by: Kush Kush ]
 
Mel Oyello
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx man, but what does the
"
int i=Integer.parsenInt(Input.getInput());
"
line mean?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic