0

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.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
snowflake
  • 77
  • 1
  • 8
  • 1
    `When i close it i cant open it once more.` Perhaps you wish to hide the window rather than `dispose` the window eg `setVisible(false);` – copeg Sep 21 '16 at 18:34
  • i think it wont solve my problem, but thanks ;) – snowflake Sep 21 '16 at 18:42
  • 1) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). 2) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Sep 22 '16 at 00:11

0 Answers0