public class Main extends JFrame{
JLabel lb1,lb2,lb3,lb4;
Button b,b1;
public Main()
{
setLayout(null);
Container c=getContentPane();
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().setBackground(Color.red);
setVisible(true);
b1=new Button("CONTINUE");
b1.setFont(new Font("Algerian", 1, 20));
b1.setForeground(Color.black);
b1.setBounds(550, 480, 200,40);
b1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{ setVisible(false);
try {
new Frame();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
c.add(b1);
setSize(1290,900);
}
public static void main(String...s) throws InterruptedException
{
new Main();
}
}
this is the main class..and this the frame class that it calls..
public class Frame extends JFrame{
Frame() throws InterruptedException
{
JFrame f=new JFrame();
f.setVisible(true);
f.setLayout(null);
f.setBounds(0,0,200,200);
Container p=f.getContentPane();
p.setBackground(Color.GREEN);
f.setResizable(false);
Thread.sleep(5000);
setVisible(false);
new Frame1();
}
}
the main class calls the frame class..that needs to hold for a certain time and then move to another frame.. but what happens is that the main class calls it, the frame appears , but there is no content in it..nothing is displayed.then it moves to frame1()//
but if i run like
new Frame();
then it holds ,shows content , and then moves..
so why doesnt it work when Frame() is called by Main() ?
even this code doesnt' work ..instead of Thread.sleep()...this way i am not blocking any even thread..am i ?
for(double i=0;i<30;i++)
{
for(double j=0;j<10000;j++)
{
}
}
new Frame1();