Why doesn't my JFrame repaint when I set a new Synthetica theme?

后端 未结 1 625
甜味超标
甜味超标 2021-01-23 12:44

I just set my applications theme to Synthetica Alu Oxide but some reason the JFrame doesn\'t repaint but another Synthetica theme will repaint the JFrame.

This is what m

1条回答
  •  心在旅途
    2021-01-23 13:12

    Swing GUI objects should be constructed and manipulated only on the event dispatch thread, after you've invoked UIManager.setLookAndFeel().

    try {
        UIManager.setLookAndFeel(new SyntheticaAluOxideLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            JFrame frame = new JFrame();
            …
            frame.pack(true);
            frame.setVisible(true);
        }
    });
    

    0 讨论(0)
提交回复
热议问题