File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Making a fake console that constantly updates and redirects system.out

 
Ollie Relent
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

So i've essentially got a GUI step up with cardlayout and gridbaglayout. I'm drawing in information from hardware, processing it and performing corresponding actions based on the data. However all my outputs are currently displayed in the console.

To get my GUI panels changing correctly whilst other methods were working I've had to use the swingutilities.invokelater method. I have a object inside an invoke later that reads in data and has many system.out.printlns in

I made a fake console using http://stackoverflow.com/questions/342990/create-java-console-inside-the-panel

However, it does not update dynamically. One of my methods is essentially an infinite loop which looks for certain data and displays outputs based on the value of the data. The normal console updates correctly with this but the JTextArea seems to only update when a method is finished.

Could someone show/explain how to make it run in real time?

Thanks

 
Ben Ooms
Ranch Hand
Posts: 47
Debian Eclipse IDE Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ollie,

Don't know exactly what you want to achieve but it looks like you want to process something in the background and update swing components when the background task executes. Did you have a look at Swingworker, might suit your needs. I recently did something with it when updating a view with a connected Arduino on the USB port. https://bitbucket.org/bendh/jenkinstoarduino . Look at the MainFrame class and it's inner class StatusUpdateTask.

regards,
Ben
 
Ollie Relent
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, essentially i have a method which streams from hardware and prints the values of arrays to the console. As a .jar does not have the console as eclipse does, i need a way of showing the output real time within the jframe.

Therefore, this is why I wanted to get it running real time. I tried updating the GUI with swing worker but it still doesnt do it realtime, it does it at the end of my streaming data method which is not what i want.

Any ideas?

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic