Gui problem with java substance Look And Feel

喜夏-厌秋 提交于 2019-12-02 08:35:22

agreed with @Joey

if you have original code source from Java.net by Kirill then there are plenty examples that show you

1 ) install UI before

UIManager.installLookAndFeel("Substance " + sInfo.getDisplayName(), sInfo.getClassName());  SwingUtilities.invokeLater(new Runnable() {     @Override       public void run() {            someMainclass.setVisible(true);       } });  

2) your issue with required SwingUtilities.updateComponentTreeUI(someWindow) packed in the try - catch

for (Window w : Window.getWindows()) {   SwingUtilities.updateComponentTreeUI(w); } 

3) or safiest way, sure with extract top-level containers for point 2dn

SwingUtilities.invokeLater(new Runnable() {          @Override         public void run() {             try {                 UIManager.setLookAndFeel(new SubstanceOfficeSilver2007LookAndFeel());                 SwingUtilities.updateComponentTreeUI(frame);             } catch (UnsupportedLookAndFeelException e) {                 throw new RuntimeException(e);             }         }     });     SwingUtilities.invokeLater(new Runnable() {  

4) you can switch theme(s), L&f, mixing Themes but must be wrapped inside InvokeLater()

5)

EDIT:

@rauch as I mentioned Substance is very sensitive to the EDT, really forgot replace Model from BackGround task without deepest knowledge about EDT and its single threading rules,

hmmm I tried that with replace model directly to avoid some of arrayIndexException plus some exception(s) from Substance (I forgot that that's some month back),

you never fool that with javax.swing.Timer or SwingWorker, sometimes (I think that HightLighter ??? or something from Trident.jar refuse to works correctly ??? and overRun EDT queue) never ever solved that for details,

just I wraped everything (output from Backgroung task to the GUI) to the AbstractAction

EDIT 2. as I read comment by @kleopatra (by mistake I ignore her advice)

would be my first guess as well - were it not Substance: usually it throws  on not being on the EDT. Plus: s/he states that the first snippet is placed  inside the invokeAndWait to let it run on the EDT 

follows her suggestion, Sustance has own L&f for SwingX, and for me SwingX == kleopatra, I can't give you workAround for that because I really hate invokeAndWait and I avoiding of usage this method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!