aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Redirecting Output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Redirecting Output" Watch "Redirecting Output" New topic
Author

Redirecting Output

Richard Davis
Greenhorn

Joined: Jul 05, 2004
Posts: 12
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
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Send a reference so the other (JPanel) classes can post their updates directly from their event code as needed.
Richard Davis
Greenhorn

Joined: Jul 05, 2004
Posts: 12
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

Joined: Jul 05, 2004
Posts: 12
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

Joined: Jul 05, 2004
Posts: 12
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Redirecting Output