java swing设置frame的高度或图标

时间:2021-10-27 09:21:05

Toolkit kit = Toolkit.getDefaultToolkit();
       

        Dimension dimension = kit.getScreenSize();

       

        int screenHeight = dimension.height;

        int screenWidth = dimension.width;

       

        setSize(screenWidth / 2, screenHeight / 2);

       

        setLocationByPlatform(true);

       

        Image img = kit.getImage(this.getClass().getResource("Nbrcats2_icon[1].gif"));

       

        setIconImage(img);

       

        setTitle("SizedFrame");