我正在显示来自 JFrame 的对话框,但是当我在对话框外部单击时,对话框会被隐藏。除非你关闭它,否则对话框应该不会让你什么都不做?
这是我的代码:
从第一个对话框调用的对话框:
JProductStocking jps = JProductStocking.getProductStoking(JPanelTicket.this, oApp);
jps.setVisible(true);
这是 JDIalog 称为:
public class JProductStocking extends javax.swing.JDialog implements BeanFactoryApp{
public JProductStocking(Component parent, boolean modal) {
//super(parent, modal);
initComponents();
}
public static JProductStocking getProductStoking(Component parent, AppView app) {
Window window = getWindow(parent);
JProductStocking myMsg;
if (window instanceof JFrame) {
myMsg = new JProductStocking((Frame) window, true);
} else {
myMsg = new JProductStocking((Dialog) window, true);
}
myMsg.init(app, parent);
myMsg.applyComponentOrientation(parent.getComponentOrientation());
return myMsg;
}
private static Window getWindow(Component parent) {
if (parent == null) {
return new JFrame();
} else if (parent instanceof JFrame || parent instanceof Dialog) {
return (Window) parent;
} else {
return getWindow(parent.getParent());
}
}
public void init(AppView app, Component parent) {
oApp = app;
// m_dlSales = (DataLogicSales) app.getBean("com.openbravo.pos.forms.DataLogicSales");
initComponents();
ProductList = new ArrayList();
this.setResizable(false);
setLocationRelativeTo(parent);
}
}
我没有很好地调用 jDialog 吗?或者我做错了什么?