can we exit from Java application automatically ?
[nobr]HI friends,
i have a requirement that is........
program controller should exit from the application, when u run this program at command prompt.
And user must not use System.exit(1) method in the loop
OR the user shouldnt give any DOS command like CTRL+C,
becoz the controller must exit automatically.
plz help me if any body can do this.
code is here..........
\\
import java.awt.*;
import javax.swing.*;
import java.util.*;
publicclass CustomDialogextends JPanel{
JFrame frame;
public JDialog dialog;
java.util.Timer schedulerTimer;
public CustomDialog(){
dialog =new JDialog(frame,"");
JLabel label =new JLabel("<html><p align=center>"
+"High Speed Transmission is .<br>"
+"going to take place ");
label.setHorizontalAlignment(JLabel.CENTER);
Font font = label.getFont();
label.setFont(label.getFont().deriveFont(font.PLAIN,14.0f));
label.setForeground(Color.black);
JPanel contentPane =new JPanel(new BorderLayout());
contentPane.add(label, BorderLayout.CENTER);
contentPane.setOpaque(true);
dialog.setContentPane(contentPane);
dialog.setSize(new Dimension(300, 150));
dialog.setLocationRelativeTo(frame);
dialog.setVisible(true);
schedulerTimer =new java.util.Timer();
schedulerTimer.schedule(new SchedulerTask(),5*1000, 10*1000);
}
publicstaticvoid main(String args[]){
new CustomDialog().m2();
}
void m2(){
for(int i=0;i<=50000;i++){
System.out.println("success"+i);
}
}
class SchedulerTaskextends TimerTask{
publicvoid run(){
schedulerTimer.cancel();
dialog.setVisible(false);
dialog=null;
frame=null;
}
}
}
[/nobr]

