Sign in to follow this  

Pausing output in text area-Java

This topic is 2545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there folks,

So I am creating a text based rpg in Java for practice and in order to keep my chops sharp during the winter break and I had question one of you might know the answer to.

I am printing text output to a text area within a GUI and I was wondering if it was possible to pause output and require the user to press enter to continue in order to allow them to read at their pace.

I have checked the API and online but I have found nothing to really answers my specific problem. All the thread out there about pausing refer to pausing the console and not a text area. Any help would be much appreciated! Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by nobodycool
I am printing text output to a text area within a GUI
It might help if you explain how you are accomplishing this. My first impulse would be to update the text area in chunks of text at a time and enable your pause mechanism after every chunk is added to the text area.

Share this post


Link to post
Share on other sites
IIRC a console in J6 is just another sort of writer, so you might attach a console to a text area.

Another way - like nobodynews hinted - would be to add chunks/lines to your text area. Create a list of chunks (e.g. a dequeue) and listen on key events within the text area. If the user presses a certain key (e.g. return) add the next chunk from the list to the text area.

Maybe the text area could just display the chunks from another list so you could remove old entries. Then you'd just need to move chunks from one list to another when the user presses the key.

Share this post


Link to post
Share on other sites
I actually worked on it last night and managed to figure out a solution. What I am doing is appending text to a textArea for output. I created a dummy action listener that requires the user to press enter, upon pressing enter the next part of the text displays. Not the most elegant of solutions but suits my needs. Thanks for the advice!

Share this post


Link to post
Share on other sites

This topic is 2545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this