JFrame and Nimbus Look And Feel

后端 未结 5 1909
名媛妹妹
名媛妹妹 2021-01-03 09:54

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.

How can JFr

5条回答
  •  甜味超标
    2021-01-03 10:29

    This is how I do. A copy paste from my eclipse project.

    import javax.swing.UIManager.LookAndFeelInfo;
    import java.awt.EventQueue;
    import java.awt.BorderLayout;
    import javax.swing.*;
    public class Frame1 {
        private JFrame frame;
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    try {
    
                         for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                                if ("Nimbus".equals(info.getName())) {
                                    UIManager.setLookAndFeel(info.getClassName());
                                    break;
                                }
                            }
                    Frame1 window = new Frame1();
                        window.frame.setVisible(true);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    

提交回复
热议问题