Win a copy of Microservices in Action this week in the Web Services forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Redirecting Output  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm probably just being dumb here, as I'm new to Java, but here goes:

I have a JPanel, containing 2 seperate JPanels and a JScrollPane. The JPanels are both instances of seperate classes (which extend JPanel), which contain all the required bits for various tasks (eg. connecting to another system).

What I want to do is reflect status updates etc (as text) from these sub-panels to the JScrollPane in the main panel. I thought about writing the status updates to a StringBuffer belonging to the sub-panels, and then retrieving this and writing it to the JScrollPane, but as the events within these panels (which generate the status updates) are all driven from within the classes I don't know how to trigger the text to be written back to the JScrollPane.

An alternative might be to re-direct the System.out.println() output to the JScrollPane, but I don't know if this is possible...

Help!

Richard
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Send a reference so the other (JPanel) classes can post their updates directly from their event code as needed.
 
Richard Davis
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Craig - works like a charm...
...however, in a couple of places I'm creating the 'other' class from within an inner class of the main ('Central') class (specifically the actionPerformed method of a button listener class, implementing ActionListener) - how in this case do I reference the 'this' of the outer class to pass to the constructor of the 'other' class?
 
Richard Davis
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Craig - works like a charm...
...however, in a couple of places I'm creating the 'other' class from within an inner class of the main ('Central') class (specifically the actionPerformed method of a button listener class, implementing ActionListener) - how in this case do I reference the 'this' of the outer class to pass to the constructor of the 'other' class?
 
Richard Davis
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hang fire on that - I've got it!

Cheers for the help,

Richard

ps: If anyone cares, I added:



to the outer code, and could then pick up the variable myCentral within the inner class to pass on to the other classes
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!