java如何检查JFrame是否存在
我想创建一个jbutton,其中包含调用jframe的函数,但是如果jframe已经被调用并且存在,jbutton必须能够停止调用它。我们怎么能做到呢
JButtonCallJFrame.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//step 1 - check if jframe already open/called or not
//step 1.a - if true ignore, jbutton do nothing
//step 1.2 - else if false,jbutton called for jframe
ClassWithJFrame cwjFrame = new ClassWithJFrame()
if(cwjFrame is exist){
//DO NOTHING
}
else if(cwjFrame not exist){
cwjFrame.setVisible(true);
}
}
});
# 1 楼答案
使用^{}