我一直在尝试将 jFrame 更改为 jDialog,以便它继承主窗口的图标,但我不知道该怎么做.我尝试将它的代码从 public class jSemestriala extends javax.swing.JFrame 设置为 public class jSemestriala extends javax.swing.JDialog 但这并没有改变窗口的图标.有任何想法吗?我使用的是 NetBeans 7.0.1
I've been trying to change a jFrame to a jDialog so it inherits the icon of the main window but I don't have a clue how to do that. I tried setting it's code from public class jSemestriala extends javax.swing.JFrameto public class jSemestriala extends javax.swing.JDialog but that didn't change the icon of the window. Any ideas? I'm using NetBeans 7.0.1
推荐答案你需要指定主窗口"框架为JDialog的所有者:
You need to specify the "main window" frame as the owner of the JDialog:
// ownerframe is a JFrame; JFrame ownerframe = new JFrame(); JDialog dlg = new JDialog(ownerframe);JDialogs 有所有者框架.如果您调用构造函数 new JDialog(),则框架会为您创建,在这种情况下,框架是不可见的;或者您在其构造函数中使用 new JDialog(ownerframe) 将其提供给对话框.
JDialogs have owner frames. The frame is either created for you if you call the constructor new JDialog(), in which case the frame is invisible; or you supply it to the dialog in its constructor using new JDialog(ownerframe).
更多推荐
将 jFrame 更改为 jDialog?
发布评论