Results 1 to 9 of 9
Thread: [help] Java text reader
- 05-25-2010, 05:24 PM #1
Member
- Join Date
- May 2010
- Posts
- 12
- Rep Power
- 0
[help] Java text reader
Well im currently working on a game and I cant figure out how to make it constantly look for text.
Im trying to make it so a user can press a button and it will do stuff instead of having to have a readln to see if the user pressed the button it will allready be looking for user input. Like in maplestory,runescape,wow ect... you can always insert text and when you inseret a certain thing like @help it dose something different. So how would i go about making a method or class that will constantly look for user input while still being able to run the main program?
- 05-25-2010, 06:05 PM #2
Is this a GUI program or commandline? Much easier to do if your have text fields for user input.
With text fields, instead of constantly looking for input, your program uses listeners. Then when the text field changes your code is called.
From the details of your post, this may be too advanced.
Perhaps if you explain a bit more about how the app is suposed to work.
- 05-25-2010, 06:42 PM #3
Member
- Join Date
- May 2010
- Posts
- 12
- Rep Power
- 0
its command line. I have like preset commands with it like if the user enters w it will do this or if they press h it will do this ect.. but i dont know how to make it automatically register it when they press it. Right now i have to ask them to enter the letter then have a readline to see if they pressed it. Is there any way to do what im trying to w/o having a gui text feild?
- 05-26-2010, 12:16 AM #4
I'm not sure exactly what it is you are trying to do.what im trying to
Without a GUI, you have to ask the user for input, read the input, do something, then go back and do it again.
How is what you want to do different than this approach?
With GUI there is code that is part of the JRE that can react when the user has pressed a key and tell the program about it. This can be done with listeners.
- 05-26-2010, 01:20 AM #5
Member
- Join Date
- May 2010
- Posts
- 12
- Rep Power
- 0
so the only way i can do what i want is with a gui?
- 05-26-2010, 02:09 AM #6
Can you explain what do you want again?
That could describe reading input from the commandline.if the user enters w it will do this or if they press h it will do this
What does "register it" mean here?how to make it automatically register it when they press it
What is the program going to be doing while it is waiting for text to be entered? Animation?make it constantly look for text.
- 05-26-2010, 05:24 PM #7
Member
- Join Date
- May 2010
- Posts
- 12
- Rep Power
- 0
There is no visuals in the game it is only text. its like civilization or dwarf fortress w/o visuals
so while the program is waiting for text input it will be telling whats going on. Like it will be saying "the river is about to flood" in which case you would want to press w to make a worker. but the way i have it set up right now after i say the river is about to flood i would have to have an input to check if the user pressed w to make a worker. What i want is so i dont have to check if the user pressed a button. I want it to automatically check. and by automatically i mean it dosnt just check if the user pressed w so say the user wanted to save insted of build a worker he/she would press "s" but it would be looking for "w" and not "s" i need something that would look for all my commands.
- 05-26-2010, 06:07 PM #8
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
You could try reading the input in another thread, however I don't think input is registered until enter is hit.
- 05-26-2010, 06:44 PM #9
Similar Threads
-
RSS Reader
By dage_001 in forum NetworkingReplies: 16Last Post: 04-25-2010, 01:41 PM -
compiler error:"AWT-EventQueue-0" java.lang.NullPointerException at java.io.Reader.
By Ms.Ranjan in forum New To JavaReplies: 4Last Post: 04-23-2010, 01:54 PM -
help with input reader
By masterhoulahan in forum New To JavaReplies: 2Last Post: 03-25-2009, 05:12 AM -
Java file reader...?
By prabhurangan in forum New To JavaReplies: 3Last Post: 11-21-2008, 08:19 AM -
Maze reader
By bix in forum New To JavaReplies: 1Last Post: 11-20-2008, 06:06 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks