Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes ?? Is it possible to.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "?? Is it possible to...." Watch "?? Is it possible to...." New topic
Author

?? Is it possible to....

Mike Smike
Ranch Hand

Joined: Aug 25, 2004
Posts: 33
Hi guys,

I'm trying to write a program in java, that displays a grid of squares, and then prompts 2 players to input co-ordinates at the command line, turn by turn. The idea is that eventually, they will be moving numbers from one square on the grid to another, specifying the direction.

I've managed to create (with help) a grid of co-ordinates. Is it possible to have the command line running at the same time as the GUI grid? So for example, I can type (0,2) NW at the command line, and when I hit ENTER, the number at (0,2) will move North West?

I understand how to use BufferedReaders and how to take input to the program on the fly, but so far, my program asks for input, THEN displays the grid, and won't do both simultaneously. Is this possible?

Thanks loads for your help guys, I really appreciate it!

Mike
Mike Smike
Ranch Hand

Joined: Aug 25, 2004
Posts: 33
Hang on, I've had a bit of a hack at it and have made a bit of progress. However, a problem still remains.

I have the code
I have the grid running at the same time. To enter in the coordinates at the command line, I click on the coordinates on my GUI grid. They do indeed appear on the command line, under where it says "Enter the coordinates". But for some reason, they are not read by the Reader, because the only output is "hello" and then nothing. Is this because I did not enter them manually using the keyboard? I've looked on the Java API for a BufferedReader method which takes input from a program's output but can't seem to find one! Am I being really stupid?

Thanks everyone,

Mike
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
you have a GUI, I guess using Swing or (shudder) AWT?
Then why not add an input box to that where the user can type his input.
On hitting enter that box will generate an event in which you can read out the content of the box.


42
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ?? Is it possible to....
 
Similar Threads
label in coordinates
Problems to be solved: need some good logic
drawing with the mouse and zooming
Reading in Program Output at command line...?!?
coding problem : Mars rovers