Hi All,
Need one more help...
I have created a simple swing frame that will pop-up another frame in certain time of intervals. Each pop-up frames contain a close button, on clicking which, the popup frame should be closed. I am using dispose() method to close those frames.
If only 1 frame is there in the screen, it's working properly. But I wait for few more time, and allow 3-4 frames to popup, then this close button is not working properly. Only the latest popup frame is getting closed. For all other popups it's not working.
Attaching the parts of my code I have written:
Paints the main frame:
public void paintFrame()
{
jf01 = new JFrame("Iconify Deiconify");
jf01.setSize(300,200);
jf01.setLocation(300,250);
jp01 = new JPanel();
jp01.setBackground(Color.BLACK);
jb01 = new JButton("Click to minimize...");
jb01.addActionListener(this);
jp01.add(jb01);
jf01.add(jp01);
jf01.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf01.setVisible(true);
}
Paints the popup frames:
public void paintAnotherFrame()
{
jf02 = new JFrame("Reminder Window");
jf02.setSize(200,100);
jf02.setLocation(200,200);
jp02 = new JPanel();
jp02.setBackground(Color.BLACK);
jb02 = new JButton("close");
jb02.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent exx)
{
jf02.dispose();
}
});
jp02.add(jb02);
jf02.add(jp02);
jf02.setAlwaysOnTop(true);
jf02.setVisible(true);
}
The main method: