• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 47
Netbeans IDE Eclipse IDE Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic