2

How can you prevent the JInternalFrame not to open more once, currently in my application it opens many times. Also how can I make my application run only if there is not the same application running.

This is the code for JInternalFrame

private void Cash_ButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            

    Provider provider = new Provider();
      MainMenu.add (provider);
       provider.setClosable(true);
    }
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
mohamed nur
  • 331
  • 1
  • 15

1 Answers1

1

Try adding a condition and making provider a local variable

private Provider provider = new Provider();

public Your_Class_Name(){
    provider.setClosable(true);
}

private void Cash_ButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if(provider.isVisible()) return;
    MainMenu.add (provider);
}
Arc676
  • 4,445
  • 3
  • 28
  • 44