• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

?? Is it possible to....

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic