This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization 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