我有一个NullPointerException
我不明白的。通常,当这种情况发生时,控制台会指向我的代码中的一行。这一次,它指向
at javax.swing.plaf.synth.SynthLabelUI.getPreferredSize(SynthLabelUI.java:238)
据我了解,这不在我的代码中。有人可以向我解释发生了什么吗?
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at javax.swing.plaf.synth.SynthLabelUI.getPreferredSize(SynthLabelUI.java:238)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1660)
at javax.swing.plaf.basic.BasicSliderUI.getHeightOfTallestLabel(BasicSliderUI.java:775)
at javax.swing.plaf.synth.SynthSliderUI.layout(SynthSliderUI.java:378)
at javax.swing.plaf.synth.SynthSliderUI.calculateGeometry(SynthSliderUI.java:343)
at javax.swing.plaf.basic.BasicSliderUI$Handler.componentResized(BasicSliderUI.java:1496)
at java.awt.Component.processComponentEvent(Component.java:6331)
at java.awt.Component.processEvent(Component.java:6285)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
我正在绘制自定义标签
private void setSliderLabels() {
Dictionary<Integer, JLabel> table = new Hashtable<Integer, JLabel>();
table.put(-256, new JLabel("-w/2"));
table.put(-128, new JLabel("-w/4"));
table.put(0, new JLabel("0"));
table.put(128, new JLabel("w/4"));
table.put(256, new JLabel("w/2"));
LSlider.setLabelTable(table);
QSlider.setLabelTable(table);
}