I have few issues with my swing app which looks like this app preview
This Frame is defined in Form class. Form class is building in main class, code below
public class Main {
public static void main(String[] args) {
Form form = new Form();
checkIfRunning();
}
"New doctor" button has it's own listener which check is this object is already exist. Listener is defined in Form class.
newDoctorButton.addActionListener(new ActionListener() {
private NDoctor dc = null;
@Override
public void actionPerformed(ActionEvent e) {
if (dc == null){
dc = new NDoctor();}
else dc.toFront();
}
});
Everything works fine, new window is opening as i want. second window preview "Ok" button listener below
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
NDoctor.super.dispose();
}
});
When i close it i cant open it once more.
Im sure the problem is in the main method. The "New Doctor"listener works but in run only once, when i close window it wont start until i call main method again, but this will create next Frame.
I hope you understand my problem. I will be grateful for any advice.