JFrame和Nimbus外观和感觉 [英] JFrame and Nimbus Look And Feel

查看:154
本文介绍了JFrame和Nimbus外观和感觉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中使用Nimbus Look and Feel。但是,尽管每个GUI JComponent都具有Nimbus的外观,但JFrame始终具有Windows外观。

I use Nimbus Look and Feel in a project. However, although every GUI JComponent have a Look and Feel of Nimbus, JFrame always have Windows Look and Feel.

JFrame如何拥有Nimbus外观?

How can JFrame have Nimbus Look And Feel?

编辑:操作系统:Windows XP

Operating System : Windows XP

推荐答案

尝试使用:

JFrame.setDefaultLookAndFeelDecorated(true); //before creating JFrames

有关详细信息,请参阅如何在教程中设置外观。

For more info., see How to Set the Look and Feel in the tutorial.

import javax.swing.*;

class FrameLook {

    public static void showFrame(String plaf) {
        try {
            UIManager.setLookAndFeel(plaf);
        } catch(Exception e) {
            e.printStackTrace();
        }
        JFrame f = new JFrame(plaf);
        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

        f.setSize(400,100);
        f.setLocationByPlatform(true);
        f.setDefaultLookAndFeelDecorated(true);
        f.setVisible(true);
    }

    public static void main(String[] args) {
        showFrame(UIManager.getSystemLookAndFeelClassName());
        showFrame(UIManager.getCrossPlatformLookAndFeelClassName());
        showFrame("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
    }
}

这篇关于JFrame和Nimbus外观和感觉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆