File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "?? Is it possible to...." Watch "?? Is it possible to...." New topic

?? 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 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,

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.

I agree. Here's the link:
subject: ?? Is it possible to....
It's not a secret anymore!