簡體   English   中英

如何在JFrame的標題欄中添加圖像圖標?

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

我需要在JFrame標題欄中添加圖像,有人可以告訴我這樣做的方法嗎?

您可以使用Window#setImageIcons(List<Image>)來提供一系列不同的大小,從而允許基礎平台選擇最適合該平台以及外觀的圖標。

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

使用frame.setIconImage(Image image)有關詳細信息,請參見http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html 使用BufferedImage表示您的圖像。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM