0

I have been using java for some time, and can code back end stuff with ease. GUI's on the other hand I Find hard to deal with.

So anyway, I'm making a game (text based), and would like to implement a console type GUI. I have already made a jframe that has a jtextfield and jtextarea. I can update the text area easily and have an action listener on the jtextfield so that I can pass through the text that I type.

The issue I am having is with the 'player' class not waiting for the input when I attempt to give the player a name. I currently have the program set up so that the main class creates the GUI, and then creates the player object. I have the scanner object inside the player set to get the text from the jtextfield on the GUI. When I do the assignment statement:

name=input.next();

The program automatically assigns what is in the jtextfield, nothing, and makes the name null. I want to make it act like if I were getting input through System.in, and make it wait till I have input in the jtextfield.

Any suggestions?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Arkheart
0

Good idea, but I don't think that will fully work with a game, having a large amount of pop ups. I would prefer to have a static window with an input field and output field.

I can use it for now though.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.