Button actionlistener. (r is the call method for my class i call it above Run r= new Run();
. it sets the window invisible but when it's supposed to get it back visible the program closes without any errors. Tried instead of setVisible(false);
dispose();
but same problem.
about.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFrame a=new JFrame("About");
a.addWindowListener(new WindowListener(){
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent arg0) {
}
@Override
public void windowClosing(WindowEvent arg0) {
r.gui.setVisible(true);
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
r.gui.setVisible(false);
}
});
a.setSize(400, 400);
a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
a.setVisible(true);
a.setLayout(null);
JLabel lbl=new JLabel("This game was made by your lovely neighbourhood takisp22");
lbl.setSize(500,50);
lbl.setLocation(0,0);
a.setLocation(100,50);
a.add(lbl);
}
});
Other Class which runs the program:
import javax.swing.JFrame;
public class Run {
public static GameAim gui=new GameAim();
public static void main(String[] args){
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setTitle("Aim Training");
gui.setSize(1280, 800);
gui.setVisible(true);
gui.setLocation(100,50);
gui.setResizable(false);
gui.openFile();
gui.readFile();
gui.closeFile();
}
}