how to take input and verify input in Java
I have 3 questions with slight changes, I would be thankful to you if you can help me solve this problem, I consulted some books and web sites but did not found the solution, the questions are as follows:
1) I want to make a Java console program which when executed will ask the user to enter some input from the key board on the command prompt,now suppose if the user enters Ctrl-F3 than a message would be printed that "you have entered the correct input", but if the user enters any other key or a combination of various key a message will be printed "you did not entered the correct key". Now my question is that how will I take input and after that on what basis will I cehck that a combination of paticular keys(Ctrl-F3) is pressed, I mean that what will be the basis of the IF ceck and what is the thing which I am going to check? If any one cal mail some sample code for this program I would really be thankful, or if you can give some oter important resources?
2) Now my second question is just an extension fo the first question with some slight variations.The thing which I was doing in previous question on a console based program I will now have to do it in GUI based program, I mean that now when I run my program a form(frame a JFrame or Frame) it will ask the user to enter some input from the key baord again if the user presses Ctrl-F3 than a message will be displayed taht you have entered correct input for any other key or key combinations tahnsome other message will be displayed, now here also my question is the same tat how will I take input,than how will I check this input and on what basis will I identify Ctrl-F3 key press.
3) The third question is same as the first two questions,but here my Java program is running like a Windows process I mean that when ever I start my computer this program starts nning at the back end in Windows(Win XP OS),and the program is continiously tracking all the key presses by the users if some user enters Ctrl-F3 a message will be displayed and if the user enters any other key or combination of keys than nothing will happen,how can I achive this and again I am asking that on what basis will I check the suer input,what will be the IF check,and how can I take input.
Please all reply soon because I consulted some books and web sites but did not found the solution,please guide me,I would be thankful to all of you people.
1. In a non-GUI environment, you would generate a "Please Enter your input" and then capture that input (Scanner or some other IO buffer). Once you have captured the input to a memory location (variable), you would then test the content of that variable and, if it matched, then your program would perform a certain task otherwise do another.
2. When you have a "GUI component", it can monitor Key presses which generate KeyEvents which can be dispatched to a KeyListener you have implemented. When the Ctrl-F3 combination is detected your program will perform a certain task. Otherwise it will do nothing or will display another message. Take a look at the JavaTutorial Trail on events and Listeners at
3. In order to monitor the events in the operating system, including what key presses are occurring in other programs are doing, you'll need to look at JNI
By jareivy05 in forum Java
Last Post: 12-07-2005, 10:11 PM
Last Post: 05-22-2002, 08:48 AM
By Steven L. Southerland in forum Enterprise
Last Post: 02-24-2001, 01:39 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL