用这么一个Contructor: public YourDialog(Frame parent) { super(parent, true); // your code... }
public YourDialog(Frame parent) { super(parent, true); // your code... } 这样不行啊,他只能跟注一个父窗体,可是我现在没有固定的父窗体怎么办?我的意思是这个Jdialog要一直在最前面。不会因为开别的窗体而隐到后面。还请各位帮忙,谢谢!
jDialog.addWindowFocusListener(new WindowAdapter(){ public void windowLostFocus(WindowEvent e){ e.getWindow().toFront(); } });
JDialog public JDialog(Dialog owner, String title, boolean modal) throws HeadlessException Creates a modal or non-modal dialog with the specified title and the specified owner frame. This constructor sets the component's locale property to the value returned by JComponent.getDefaultLocale. Parameters: owner - the non-null Dialog from which the dialog is displayed title - the String to display in the dialog's title bar modal - true for a modal dialog, false for one that allows other windows to be active at the same time 用模态窗口吗?
public SendAndReceiveMessageDialog(Frame frame, String title, boolean modal) { super(frame, title, modal); initialize();//构造对话框 } public SendAndReceiveMessageDialog() { this(frame,"", false); }frame是你弹出对话框的父窗体. 这个Jdialog会一直在最前面。不会因为开别的窗体而隐到后面
public SendAndReceiveMessageDialog() { this(frame,"", false); }frame这个frame为null好像也可以的.
{
super(parent, true);
// your code...
}
{
super(parent, true);
// your code...
}
这样不行啊,他只能跟注一个父窗体,可是我现在没有固定的父窗体怎么办?我的意思是这个Jdialog要一直在最前面。不会因为开别的窗体而隐到后面。还请各位帮忙,谢谢!
public void windowLostFocus(WindowEvent e){
e.getWindow().toFront();
}
});
public JDialog(Dialog owner,
String title,
boolean modal)
throws HeadlessException
Creates a modal or non-modal dialog with the specified title and the specified owner frame.
This constructor sets the component's locale property to the value returned by JComponent.getDefaultLocale.
Parameters:
owner - the non-null Dialog from which the dialog is displayed
title - the String to display in the dialog's title bar
modal - true for a modal dialog, false for one that allows other windows to be active at the same time 用模态窗口吗?
super(frame, title, modal);
initialize();//构造对话框
}
public SendAndReceiveMessageDialog() {
this(frame,"", false);
}frame是你弹出对话框的父窗体. 这个Jdialog会一直在最前面。不会因为开别的窗体而隐到后面
this(frame,"", false);
}frame这个frame为null好像也可以的.