如何在JFrame的标题栏中添加图像图标? [英] How to add images icon in the title bar of JFrame?

查看:117
本文介绍了如何在JFrame的标题栏中添加图像图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 JFrame 标题栏中添加图片,有人可以告诉我这样做吗?

I need to add image in JFrame title bar, can anybody tell me the way to do this?

推荐答案

您可以使用 Window#setImageIcons(List< Image>) 允许您提供一系列不同尺寸,允许选择最适合平台和外观的图标的基础平台...

You could use Window#setImageIcons(List<Image>) which allows you to supply a series of different sized, which allows the underlying platform to choose a icon that is best suited to the platform and look and feel...

List<Image> images = new ArrayList<Image>(4);
images.add(ImageIO.read(getClass().getResource("/icons/icon16x16.png"));
images.add(ImageIO.read(getClass().getResource("/icons/icon24x24.png"));
images.add(ImageIO.read(getClass().getResource("/icons/icon32x32.png"));
images.add(ImageIO.read(getClass().getResource("/icons/icon48x48.png"));

frame.setImageIcons(images);

这篇关于如何在JFrame的标题栏中添加图像图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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