gpt4 book ai didi

java - 如何调整图标大小?

转载 作者:行者123 更新时间:2023-12-01 10:17:21 24 4
gpt4 key购买 nike

我更改了 JFrame 的图标。但这是非常小的。所以我想改变它的大小。请帮忙

import java.awt.*;

//@SuppressWarnings("serial")
public class FrameD extends JFrame{

public FrameD(){


ImageIcon icon = new ImageIcon("C:\\hilalekinci\\fiha.png");

this.setTitle("FiHa");
this.setSize(750,550);
this.setIconImage(icon.getImage());
this.setLayout(null);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocation(300,80);


}

public static void main(String[] args){
new FrameD();
}
}

最佳答案

简短的回答,你不能。窗口的图标大小由运行应用程序的窗口管理器控制。有些窗口管理器甚至不显示图标。

您可以提供不同大小的替代图标(请参阅方法 setIconImages() ),但窗口管理器将决定显示哪个图标。请参阅javadoc :

public void setIconImages(List<? extends Image> icons)

Sets the sequence of images to be displayed as the icon for this window. Subsequent calls to getIconImages will always return a copy of the icons list.

Depending on the platform capabilities one or several images of different dimensions will be used as the window's icon.

The icons list is scanned for the images of most appropriate dimensions from the beginning. If the list contains several images of the same size, the first will be used.

Ownerless windows with no icon specified use platfrom-default icon. The icon of an owned window may be inherited from the owner unless explicitly overridden. Setting the icon to null or empty list restores the default behavior.

Note : Native windowing systems may use different images of differing dimensions to represent a window, depending on the context (e.g. window decoration, window list, taskbar, etc.). They could also use just a single image for all contexts or no image at all.

关于java - 如何调整图标大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35815487/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com