简体   繁体   中英

How to add images icon in the title bar of JFrame?

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

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);

use frame.setIconImage(Image image) see http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html for details. Use BufferedImage to represent your image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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