将 jFrame 更改为 jDialog? [英] Change jFrame to jDialog?

查看:35
本文介绍了将 jFrame 更改为 jDialog?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆