Question

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);
    }
Was it helpful?

Solution

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top