Phebus40
Phebus40

Reputation: 173

Integrate java console in a GUI

i've a GUI (done with eclipse and windowbuilder), i would like to open (in a jframe or in a new window near from my GUI) a console which displays my System.out.println and my printstacktrace (inter alia).

How can i do that? Do i really have to develop a console?

(I don't want to be sure that the user launched my jar from his cmd.exe)

Upvotes: 2

Views: 1616

Answers (2)

dubermen
dubermen

Reputation: 209

There is a SourceForge project that will pop a console window for displaying multiple object types.

From the project:

Description

The Java42 Development Console is a replacement for Java's System class. This is a development tool intended to be used during application development but can also be packaged and shipped with your product.

Example usage:

import java42.lang.System;

System.getManager().initialize(owner); // Owner is your app's JFrame

// All System.out.xxx methods are routed to the console.

// Print text:
System.out.println("Hello Console"); 

// Print components:
System.out.println(new JButton("Hello Console")); 

// Print images:
System.out.println(ImageIO.read(imageStream));

enter image description here

Upvotes: 2

OpenSauce
OpenSauce

Reputation: 8623

Using System.setOut and System.setErr, you can re-direct console output to PrintStreams of your choice. So you can send all output to a text area inside your frame.

Upvotes: 3

Related Questions