将 jFrame 更改为 jDialog?

编程入门 行业动态 更新时间:2024-10-12 20:21:29
本文介绍了将 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?

本文发布于:2023-10-27 10:41:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533132.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:jFrame   jDialog

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!