目前我的应用程序在Windows环境中运行,并且根据新要求,我们需要Linux上的端口。
但是我的应用程序使用的是Windows外观,只在Windows平台上支持,当我在Linux上运行时,我将获得下面列出的异常。
当我计划继续使用GTK外观时,我正面临组件大小不匹配和按钮颜色等问题。
然后我用我自己的主题来看看Metal的外观和感觉,但仍然应用程序抛出同样的异常。
MetalLookAndFeel.setCurrentTheme(MyTheme());
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
public class MyTheme extends DefaultMetalTheme {
public String getName() {
return "MyTheme";
}
ColorUIResource primary1 = new ColorUIResource(0, 78, 115);
ColorUIResource primary2 = new ColorUIResource(102, 193, 122);
ColorUIResource primary3 = new ColorUIResource(153, 244, 173);
ColorUIResource secondary1 = new ColorUIResource(196, 172, 134);
ColorUIResource secondary2 = new ColorUIResource(209, 192, 163);
ColorUIResource secondary3 = new ColorUIResource(223, 211, 190);
private final FontUIResource controlFont = new FontUIResource("Dialog", 0, 11);
protected ColorUIResource getPrimary1() {
return primary1;
}
protected ColorUIResource getPrimary2() {
return primary2;
}
protected ColorUIResource getPrimary3() {
return primary3;
}
protected ColorUIResource getSecondary1() {
return secondary1;
}
protected ColorUIResource getSecondary2() {
return secondary2;
}
protected ColorUIResource getSecondary3() {
return secondary3;
}
public FontUIResource getControlTextFont() {
return controlFont;
}
}
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at javax.swing.plaf.basic.BasicButtonUI.getMinimumSize(BasicButtonUI.java:352)
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at javax.swing.JComponent.getMinimumSize(JComponent.java:1714)
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at java.awt.BorderLayout.minimumLayoutSize(BorderLayout.java:651)
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at java.awt.Container.minimumSize(Container.java:1651)
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at java.awt.Container.getMinimumSize(Container.java:1636)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at javax.swing.JComponent.getMinimumSize(JComponent.java:1716)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.FlowLayout.minimumLayoutSize(FlowLayout.java:448)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.minimumSize(Container.java:1651)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.getMinimumSize(Container.java:1636)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at javax.swing.JComponent.getMinimumSize(JComponent.java:1716)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:1094)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:893)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:2052)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:2008)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:789)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.layout(Container.java:1421)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.doLayout(Container.java:1410)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1507)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1513)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1513)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1513)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1513)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validate(Container.java:1480)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue.access$000(EventQueue.java:85)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue$1.run(EventQueue.java:603)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue$1.run(EventQueue.java:601)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.security.AccessController.doPrivileged(Native Method)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)