MyDialog_billlist myDialog_billlist;
/**
* 自定义弹框
* @author lyy
*
*/
class MyDialog_billlist extends Dialog implements ActionListener{
JButton ok = new JButton("ok");
JButton cancel = new JButton("cancel");
//加载面板
MyDialog_billlist(ScanFrame parent, boolean modal){
super(parent,modal);
setTitle("XXXXXX");
setBounds(100, 100, 800, 500);
setLocationRelativeTo(parent);//定位在父类窗口中间
setResizable(false);
//setUndecorated(true);//去掉弹框的所有边框和缩小关闭等按钮
this.addWindowListener(new WindowListener() {
@Override
public void windowOpened(WindowEvent e) {}
@Override
public void windowIconified(WindowEvent e) {}
@Override
public void windowDeiconified(WindowEvent e) {}
@Override
public void windowDeactivated(WindowEvent e) {}
@Override
public void windowClosing(WindowEvent e) {//点击自带叉叉的回调
// TODO Auto-generated method stub
myDialog_billlist.dispose();
}
@Override
public void windowClosed(WindowEvent e) {}
@Override
public void windowActivated(WindowEvent e) {}
});
setLayout(null);
add(ok);
add(cancel);
ok.setBounds(554, 435, 110, 50);
cancel.setBounds(674, 435, 110, 50);
ok.addActionListener(this);
cancel.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if (e.getSource()==ok){
//此处写入确定的代码
}else{
dispose();
}
}
}
/*
*调用
*/
if(myDialog_billlist ==null){
myDialog_billlist = new MyDialog_billlist (XXframe.this,true);
}
myDialog_billlist.show();//开启
myDialog_billlist.dispose();//销毁