简体   繁体   English

Java UI 管理器外观 (JTattoo) 导致 NULLpointer

[英]Java UI Manager look and feel (JTattoo) causes NULLpointer

I have a java project that runs with maven.我有一个使用 maven 运行的 java 项目。 I added the JTattoo to the maven dependencies and set the GUI manager to the HiFi team in the main class:我将 JTattoo 添加到 maven 依赖项中,并将 GUI 管理器设置为主类中的 HiFi 团队:

try {
                UIManager.setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel");
            } catch (InstantiationException ex) {
                Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
            } catch (UnsupportedLookAndFeelException ex) {
                Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
            }

When I run my application, Netbeans does not show any error and everything seems to work fine.当我运行我的应用程序时,Netbeans 没有显示任何错误,而且一切似乎都正常。 But when I run my application, most of my JLabels are not displayed and I get a NullPointer exception and the following stacktrace (my programm keeps running):但是当我运行我的应用程序时,我的大部分 JLabel 都没有显示,我收到了一个 NullPointer 异常和以下堆栈跟踪(我的程序一直在运行):

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:2043)
    at java.awt.Component.getLocationOnScreen(Component.java:2028)
    at com.jtattoo.plaf.JTattooUtilities.getRelLocation(JTattooUtilities.java:192)
    at com.jtattoo.plaf.hifi.HiFiUtils.fillComponent(HiFiUtils.java:42)
    at com.jtattoo.plaf.hifi.HiFiRadioButtonUI.paintBackground(HiFiRadioButtonUI.java:84)
    at com.jtattoo.plaf.BaseRadioButtonUI.paint(BaseRadioButtonUI.java:97)
    at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
    at javax.swing.JComponent.paintComponent(JComponent.java:780)

Anybody has an idea, what can cause this problem?任何人都有一个想法,什么会导致这个问题? If this problem can't be fixed are there any similar free alternatives for the JTattoo HiFi/noir theme?如果这个问题无法解决,JTattoo HiFi/noir 主题有没有类似的免费替代品?

(a) Check your Java, there is known bug https://bugs.openjdk.java.net/browse/JDK-8043705 (a)检查您的Java,有一个已知的错误https://bugs.openjdk.java.net/browse/JDK-8043705

(b) Check your library: create new hello world-like application with jtattoo l'n'f - just a JFrame + JLabel (b)检查您的库:使用jtattoo l'n'f创建一个新的Hello world-like应用程序-只是一个JFrame + JLabel

(c) Try to find the difference between hello world application and your real application. (c)尝试找出hello world应用程序与实际应用程序之间的区别。

1- import JTattoo 1.6.13 2- replace code in main 1- 导入 JTattoo 1.6.13 2- 替换 main 中的代码

public static void main(String args[]) {公共静态无效主(字符串参数[]){

      com.jtattoo.plaf.acryl.AcrylLookAndFeel.setTheme("Green", "INSERT YOUR LICENSE KEY HERE", "Company");
     try { 
    UIManager.setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel"); 
} catch(Exception ignored){
         System.out.println(ignored);}
     
     
     
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new NewjFrame().setVisible(true);
        
           
             
               
        }
    });
}

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

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