dispose() does not work here
/*
* welcome.java
*
* Created on January 29, 2009, 2:00 PM
*/
package desktopapp;
import java.lang.Thread;
/**
*
* @author innovators
*/
public class welcome extends javax.swing.JFrame{
/** Creates new form welcome */
public welcome() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jFrame1 = new javax.swing.JFrame();
jFrame2 = new javax.swing.JFrame();
jFrame3 = new javax.swing.JFrame();
jLabel1 = new javax.swing.JLabel();
javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
jFrame1.getContentPane().setLayout(jFrame1Layout);
jFrame1Layout.setHorizontalGroup(
jFrame1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jFrame1Layout.setVerticalGroup(
jFrame1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
javax.swing.GroupLayout jFrame2Layout = new javax.swing.GroupLayout(jFrame2.getContentPane());
jFrame2.getContentPane().setLayout(jFrame2Layout);
jFrame2Layout.setHorizontalGroup(
jFrame2Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jFrame2Layout.setVerticalGroup(
jFrame2Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
javax.swing.GroupLayout jFrame3Layout = new javax.swing.GroupLayout(jFrame3.getContentPane());
jFrame3.getContentPane().setLayout(jFrame3Layout);
jFrame3Layout.setHorizontalGroup(
jFrame3Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
jFrame3Layout.setVerticalGroup(
jFrame3Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
setIconImage(getIconImage());
setLocationByPlatform(true);
setMinimumSize(new java.awt.Dimension(640, 500));
setResizable(false);
jLabel1.setIcon(new javax.swing.ImageIcon("C:\\Documents and Settings\\innovators\\Desktop\\55.JPG"));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addComponent(jLabel1)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addComponent(jLabel1)
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try{
new welcome().setVisible(true);
java.lang.Thread.sleep(1500);
dispose();
new newcustomer().setVisible(true);
}catch(Exception e){}
}
});
}
// Variables declaration - do not modify
private javax.swing.JFrame jFrame1;
private javax.swing.JFrame jFrame2;
private javax.swing.JFrame jFrame3;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}
You cannot call non static method from a static method
dispose() is a method which is non static method and you are not allowed to call a non static method from static method main().
This class won't even compile with the code given above. There are many issues with this code, please go through the link given by previous comment by Darryl.Burke
Some workable code will be like:
public static void main(String args[]) {
final welcome frame = new welcome();
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
frame.setVisible(true);
}
});
try {
Thread.sleep(1500);
frame.dispose();
} catch( Exception ex) {
}
}