简体   繁体   English

设置新的Synthetica主题时,为什么我的JFrame不重新粉刷?

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

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. 我只是将应用程序主题设置为Synthetica Alu Oxide,但是由于某些原因JFrame不会重新绘制,而另一个Synthetica主题将重新绘制JFrame。

This is what mine looks like. 这就是我的样子。

http://i.imgur.com/SOBDTs4.png http://i.imgur.com/SOBDTs4.png

This is what its suppose to look like. 这就是它的样子。

http://www.jyloo.com/images/screenshots/syntheticaAluOxide/democenter2.png http://www.jyloo.com/images/screenshots/syntheticaAluOxide/democenter2.png

    public MainPanel() {
    JFrame frame = new JFrame();
    frame.setTitle("Asteria 3.0 NPC Definition Editor");

    try {
        UIManager.setLookAndFeel(new SyntheticaAluOxideLookAndFeel());
    } catch (UnsupportedLookAndFeelException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    components();       
    frame.setJMenuBar(menuBar);
    JTabbedPane tab = new JTabbedPane();
    tab.addTab("Information", informationTab());

    tab.addTab("Bonuses", bonusTab());
    tab.addTab("Animation", animTab());
    tab.addTab("Property", propertiesTab());
    tab.addTab("Miscellaneous", miscTab()); 

    frame.getContentPane().add(tab);
    //frame.add(this);
    frame.setSize(500, 600);
    frame.setResizable(false);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);     
}

Swing GUI objects should be constructed and manipulated only on the event dispatch thread , after you've invoked UIManager.setLookAndFeel() . 在调用UIManager.setLookAndFeel() 之后 ,应事件分发线程上构造和操作Swing GUI对象。

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);
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM