public static void main(String[] args) throws Exception
{
new Main().init();
Hello.main();
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(Main.UI.getContentPane());
} catch (UnsupportedLookAndFeelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
在main方法里设置皮肤,但是设置之后窗口UI包含的一些组件的监听就会失效, UI内包含一个输入单词的搜索条,
本身在没有设置皮肤的那两行时输入单词回车之后应该在UI中的一个JTextArea中显示单词注释的, 但只要加上设置皮肤的
这两行: UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(Main.UI.getContentPane());
就悲剧了, 输入单词回车之后压根就没反应,这是为什么呢?
纠结了很久没弄出来, 如果大牛们有设置Java皮肤的其它好的办法也非常欢迎~~
{
new Main().init();
Hello.main();
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(Main.UI.getContentPane());
} catch (UnsupportedLookAndFeelException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
在main方法里设置皮肤,但是设置之后窗口UI包含的一些组件的监听就会失效, UI内包含一个输入单词的搜索条,
本身在没有设置皮肤的那两行时输入单词回车之后应该在UI中的一个JTextArea中显示单词注释的, 但只要加上设置皮肤的
这两行: UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(Main.UI.getContentPane());
就悲剧了, 输入单词回车之后压根就没反应,这是为什么呢?
纠结了很久没弄出来, 如果大牛们有设置Java皮肤的其它好的办法也非常欢迎~~
前面却是
new Main().init();创建了一个Main类的对象......有点不明白.
单纯只用
SwingUtilities.updateComponentTreeUI(Main.UI.getContentPane());
的话也是同样的BUG
Main是一个类, UI是Main类里面的静态属性(Jframe)
new Main().init(); 是运行主窗口(UI)程序, 所有操作都在这个主窗口上运行
另外如果把try块放到Main.init()之前的话就一切正常, 皮肤也能换, 但这样的话就无法动态换肤了
这个之后UI里面的很多组件监听失效了