java - 如何调整图标大小?

标签 java swing user-interface icons size

我更改了 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/

相关文章:

Java requestInWindow 有时不起作用

java - Swing自定义绘画动画在达到框架的一半宽度后停止

java - 如何将我的 java swing 应用程序的连接传递到 Crystal Reports XI?

javascript - 防止使用键盘按键在 Google map 上移动

java - 用于计算量大的程序的 GUI 界面

java - 在 Java 打印对话框中隐藏 "Print to file"

java - JSF p :commandLink and p:ajax have different behavior in update

java - Spring Boot中未创建MongoDB唯一索引

将 HTTP 状态代码映射到描述的 Java 库?

java - Netty 4 解码器问题