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);
    }
4

1 回答 1

1

尝试添加条件并制作provider局部变量

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);
}
于 2013-11-01T14:11:41.927 回答