i want to hide the previous window frame when a new window appear after pressing the submit button,how to hide the previous window or close it without pressing cross button
enter code here
public static void main(String[] args)
{
JFrame frame = new JFrame("Project Format Creator");
JButton btn5 = new JButton("submit");
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints cst = new GridBagConstraints();
cst.fill = GridBagConstraints.HORIZONTAL;
cst.gridx = 0;
cst.gridwidth = 1;
cst.weightx = 0.1;
cst.gridy = 8; //third row
panel.add(btn5,cst);
btn5.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JFrame frame1 = new JFrame("Project Format Creator");
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame1.setSize(300,300);//int width int height
frame1.getContentPane().add(panel);
frame1.setVisible(true);
}
});
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);//int width int height
frame.getContentPane().add(panel);
frame.setVisible(true);
}