Vi.
Vi.

Reputation: 38694

How should JVM/Swing GUI application show console?

The application creates and displays various Swing widgets, and also writes debugging messages to System.out. If I start it as java -jar ...jar then I see it, but if I click on jar file in GUI I don't see the console. How to make it show console to user explicitly, e.g. on reaction to "View -> Debug output" menu item?

Expecting something that will pop up cmd.exe window on Windows, xterm/... on Linux, but it may be Swing window as well. How to do it the easily?

Upvotes: 1

Views: 1825

Answers (3)

mKorbel
mKorbel

Reputation: 109815

I think that you looking for CTRL + SHIFT + F1 works if is GUI visible here you can see output to the console, with Tree hierarchy of JComponents

Upvotes: 1

LeleDumbo
LeleDumbo

Reputation: 9340

AFAIK on Windows the console would be displayed on the first console output (i.e. System.out.printXXX), while on Linux it must be executed from console itself to do so. I'd rather create a separate window with a JTextArea (or something similar) to display the debug output. Normal users won't care about / need it, right?

Upvotes: 0

Harry Joy
Harry Joy

Reputation: 59650

First don't use System.out to log, use some Logging framework to write logs in some file and to display the debugging logs open a new JDialog with JTextArea or JTextPane in it. Read the log file content and display that in the textArea. This way it will also solve platform dependency.

Upvotes: 3

Related Questions