Why doesn#39;t my JFrame repaint when I set a new Synthetica theme?(当我设置一个新的 Synthetica 主题时,为什么我的 JFrame 没有重新绘制?)
问题描述
我只是将我的应用程序主题设置为 Synthetica Alu Oxide,但出于某种原因 JFrame 不会重新绘制,但另一个 Synthetica 主题会重新绘制 JFrame.
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.
这就是我的样子.
http://i.imgur.com/SOBDTs4.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 对象应仅在 事件调度线程,在你调用了UIManager.setLookAndFeel().
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);
    }
});
                        这篇关于当我设置一个新的 Synthetica 主题时,为什么我的 JFrame 没有重新绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:当我设置一个新的 Synthetica 主题时,为什么我的 JFrame 没有重新绘制?
				
        
 
            
        - Eclipse 的最佳 XML 编辑器 2022-01-01
 - 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
 - java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
 - GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
 - 转换 ldap 日期 2022-01-01
 - 如何指定 CORS 的响应标头? 2022-01-01
 - 获取数字的最后一位 2022-01-01
 - 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
 - 未找到/usr/local/lib 中的库 2022-01-01
 - 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
 
						
						
						
						
						
				
				
				
				