简体   繁体   English

在JFrame形式的Java NetBeans上显示图像

[英]Display image on JFrame form Java NetBeans

I want to show a image on top this form, but I don't know how. 我想在此表单上方显示图像,但不知道如何显示。 I have tried many times, but I cant find any image container in Toolbox. 我已经尝试了很多次,但是在工具箱中找不到任何图像容器。

Screenshot of JFrame: JFrame的屏幕截图:

https://i.stack.imgur.com/ECVNl.png

but i cant find any image container I 但我找不到任何图像容器

Add an ImageIcon to a JLabel . ImageIcon添加到JLabel

Icon icon = new ImageIcon(...);
JLabel label = new JLabel( icon );
frame.add( label );

Read the section from the Swing tutorial on How to Use Icons for a working example. 阅读Swing教程中有关如何使用图标的部分,了解一个有效的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM