Skip to main content

Auto-Close console

3 replies [Last post]
Kwaz
Offline
Joined: 2006-02-17
Points: 0

How can I auto-close console window (cmd.exe) after exiting from a standalone Java Help application from the command line using a batch file to start the program?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
brinkley
Offline
Joined: 2003-06-06
Points: 0

Use V1.1.3 or V2.0 when it comes out in the next few days. There isn't a console for those.

Binky

Kwaz
Offline
Joined: 2006-02-17
Points: 0

I am the Java Help as Standalone Application from the MS-DOS command line (com.exe; ex; start myfile.bat) using a batch file (myfile.bat). When I close the help viewer the command window is still showing. I would like to be able to get the close window listener from the help viewer and call System.exit(0) to kill dos command window automatically. Thanks.

jayallen
Offline
Joined: 2006-02-17
Points: 0

JFrame helpFrame = null;
JFrame jf = null;

Frame[] frames = Frame.getFrames();

for (int k = 0; k < frames.length; k++)
{
if (!(frames[k] instanceof JFrame))
continue;

jf = (JFrame)frames[k];

if (jf.getContentPane().getComponentCount()==0)
continue;

Component c = jf.getContentPane().getComponent(0);

if (c == null || !(c instanceof JHelp))
continue;

helpFrame = jf;
}

if (helpFrame != null)
{
helpFrame.addWindowListener( new WindowAdapter () {

public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}