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?

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.