I have a Jframe called TabletAddDetails and when I click back button the Jframe TabletAddDetails will be hidden and open Jframe Tablet. There is a button in Jframe Tablet open Jframe TabletAddDetails . Is there any way that I could open the same previously hidden Jframe TabletAddDetails instead of a completely new instance of Jframe TabletAddDetails so that my progress bar update will not get lost when I come back.
Here is the code for back Buttom in Jframe TabletAddDetails
JButton btnBack = new JButton("BACK");
btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try
{
Tablet tab=new Tablet();
tab.setVisible(true);
tab.setLocationRelativeTo(null);
tab.setResizable(false);
tab.setTitle("Tablet");
setVisible(false);
try {
tab.setIconImage(ImageIO.read(new File("img/icon.png")));
}
catch (IOException exc) {
exc.printStackTrace();
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,e.getClass().getName() + ": " + e.getMessage());
}
}
});
Here is the code for Button TabletAddDetails in Jframe Tablet
JButton btnDetails = new JButton("TabletAddDetails");
btnDetails.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try
{
TabletAddDetails tabadd=new TabletAddDetails();
tabadd.setVisible(true);
tabadd.setLocationRelativeTo(null);
tabadd.setResizable(false);
tabadd.setTitle("Tablet Add Details");
setVisible(false);
try {
tabadd.setIconImage(ImageIO.read(new File("img/icon.png")));
}
catch (IOException exc) {
exc.printStackTrace();
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,e.getClass().getName() + ": " + e.getMessage());
}
}
});