在 Netbeans swing gui 构建器中设置 jFrame 的图标
我一直在尝试在 Netbean 的 GUI 构建器中设置一个窗口,但没有成功。我尝试从我的主类访问 JFrame,如下所示:
public void run(){
JFrame frame = new JFrame("Title of Frame");
frame.setIconImage(Toolkit.getDefaultToolkit().getImage("org/icon.png"));
}
它使用 icon.png 在我的主窗口之外创建了一个新框架。我想知道是否有某种方法可以访问包含其余 UI 元素的 JFrame,并设置该图标。
我也尝试过 new SearchAppUI().setIconImage(null);
这没有做任何值得注意的事情。
直接设置图标:
JFrame.setIconImage("org/icon.png");
给我错误,非静态方法 setIconImage(java.awt.Image) 无法从静态上下文中引用。
有什么方法可以从 Netbean 设置主 JFrame 的图标swing desinger 预览,还是来自我的 run() 方法?
I've been trying to set up a window in Netbean's GUI builder, without success. I've tried accessing the JFrame, from my main class as:
public void run(){
JFrame frame = new JFrame("Title of Frame");
frame.setIconImage(Toolkit.getDefaultToolkit().getImage("org/icon.png"));
}
Which creates a new frame apart from my main window with my icon.png. I'd like to know if there is some way to gain access to the JFrame that contains the rest of my UI elements, and set that icon.
I've also triednew SearchAppUI().setIconImage(null);
which doesn't do anything of note.
Setting the icon directly:
JFrame.setIconImage("org/icon.png");
gives me the error, non-static method setIconImage(java.awt.Image) cannot be referenced from a static context.
Is there any way to set the main JFrame's icon from either Netbean's swing desinger preview, or from my run() method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
OP 有点过时,但仅供记录,请尝试以下操作:
The OP is a bit dated but just for the record, try this:
NVM,我在以下位置找到了解决方案:http://www.youtube.com/watch ?v=o_35iro4b7M
描述如何设置jFrame的图标和标题。基本上,它需要
库,至少对于原型设计来说是这样。
我现在非常想坚持使用 Netbean 的 guibuilder 的
NVM, I found a solution on: http://www.youtube.com/watch?v=o_35iro4b7M
Describing how to set the icon and title of a jFrame. Basically, it requires
the libraries
I pretty much wanted to stick with using Netbean's guibuilder for now, at least for prototyping.
首先。值得阅读如何制作框架。
您可以使用以下示例。
First of all. It's worth to read How to Make Frames.
You can use the following example.