Java ToolTipText ClassCastException

时间:2015-06-16 19:06:28

标签: java tooltip classcastexception

我在IntelliJ IDEA中编程,当我向任何组件(例如JLabel)添加ToolTipText时,启动程序,并将组件悬停,我收到以下错误:

  

线程中的异常" AWT-EventQueue-0" java.lang.ClassCastException:   javax.swing.JScrollPane $ ScrollBar无法强制转换为   javax.swing.JToolTip at   javax.swing.plaf.synth.SynthToolTipUI.paint(SynthToolTipUI.java:179)     在   javax.swing.plaf.synth.SynthToolTipUI.update(SynthToolTipUI.java:141)     在javax.swing.JComponent.paintComponent(JComponent.java:778)at   javax.swing.JComponent.paint(JComponent.java:1054)at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JLayeredPane.paint(JLayeredPane.java:586)at at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JComponent.paintToOffscreen(JComponent.java:5222)at at   javax.swing.RepaintManager中的$ PaintManager.paintDoubleBuffered(RepaintManager.java:1572)     在   javax.swing.RepaintManager中的$ PaintManager.paint(RepaintManager.java:1495)     在javax.swing.RepaintManager.paint(RepaintManager.java:1265)at   javax.swing.JComponent._paintImmediately(JComponent.java:5170)at   javax.swing.JComponent.paintImmediately(JComponent.java:4981)at   javax.swing.RepaintManager $ 4.run(RepaintManager.java:824)at   javax.swing.RepaintManager $ 4.run(RepaintManager.java:807)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在   javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:807)     在   javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:782)     在   javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:731)     在javax.swing.RepaintManager.access $ 1300(RepaintManager.java:64)at   javax.swing.RepaintManager中的$ ProcessingRunnable.run(RepaintManager.java:1720)     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)     在java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)at   java.awt.EventQueue.access $ 500(EventQueue.java:97)at   java.awt.EventQueue $ 3.run(EventQueue.java:702)at   java.awt.EventQueue $ 3.run(EventQueue.java:696)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:719)at   java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)     在   java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)     在   java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)   线程中的异常" AWT-EventQueue-0" java.lang.ClassCastException:   javax.swing.JScrollPane $ ScrollBar无法强制转换为   javax.swing.JToolTip at   javax.swing.plaf.synth.SynthToolTipUI.paint(SynthToolTipUI.java:179)     在   javax.swing.plaf.synth.SynthToolTipUI.update(SynthToolTipUI.java:141)     在javax.swing.JComponent.paintComponent(JComponent.java:778)at   javax.swing.JComponent.paint(JComponent.java:1054)at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JLayeredPane.paint(JLayeredPane.java:586)at at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paintToOffscreen(JComponent.java:5229)at at   javax.swing.RepaintManager中的$ PaintManager.paintDoubleBuffered(RepaintManager.java:1572)     在   javax.swing.RepaintManager中的$ PaintManager.paint(RepaintManager.java:1495)     在javax.swing.RepaintManager.paint(RepaintManager.java:1265)at   javax.swing.JComponent.paint(JComponent.java:1040)at   java.awt.GraphicsCallback $ PaintCallback.run(GraphicsCallback.java:39)     在   sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:79)     在   sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:116)     在java.awt.Container.paint(Container.java:1973)at   java.awt.Window.paint(Window.java:3901)at   javax.swing.RepaintManager $ 4.run(RepaintManager.java:835)at   javax.swing.RepaintManager $ 4.run(RepaintManager.java:807)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在   javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:807)     在   javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:782)     在   javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:731)     在javax.swing.RepaintManager.access $ 1300(RepaintManager.java:64)at   javax.swing.RepaintManager中的$ ProcessingRunnable.run(RepaintManager.java:1720)     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)     在java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)at   java.awt.EventQueue.access $ 500(EventQueue.java:97)at   java.awt.EventQueue $ 3.run(EventQueue.java:702)at   java.awt.EventQueue $ 3.run(EventQueue.java:696)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:719)at   java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)     在   java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)     在   java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)   线程中的异常" AWT-EventQueue-0" java.lang.ClassCastException:   无法将javax.swing.JScrollPane强制转换为javax.swing.JToolTip   javax.swing.plaf.synth.SynthToolTipUI.paint(SynthToolTipUI.java:179)     在   javax.swing.plaf.synth.SynthToolTipUI.update(SynthToolTipUI.java:141)     在javax.swing.JComponent.paintComponent(JComponent.java:778)at   javax.swing.JComponent.paint(JComponent.java:1054)at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JLayeredPane.paint(JLayeredPane.java:586)at at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paintToOffscreen(JComponent.java:5229)at at   javax.swing.RepaintManager中的$ PaintManager.paintDoubleBuffered(RepaintManager.java:1572)     在   javax.swing.RepaintManager中的$ PaintManager.paint(RepaintManager.java:1495)     在javax.swing.RepaintManager.paint(RepaintManager.java:1265)at   javax.swing.JComponent.paint(JComponent.java:1040)at   java.awt.GraphicsCallback $ PaintCallback.run(GraphicsCallback.java:39)     在   sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:79)     在   sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:116)     在java.awt.Container.paint(Container.java:1973)at   java.awt.Window.paint(Window.java:3901)at   javax.swing.RepaintManager $ 4.run(RepaintManager.java:835)at   javax.swing.RepaintManager $ 4.run(RepaintManager.java:807)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在   javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:807)     在   javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:782)     在   javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:731)     在javax.swing.RepaintManager.access $ 1300(RepaintManager.java:64)at   javax.swing.RepaintManager中的$ ProcessingRunnable.run(RepaintManager.java:1720)     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)     在java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)at   java.awt.EventQueue.access $ 500(EventQueue.java:97)at   java.awt.EventQueue $ 3.run(EventQueue.java:702)at   java.awt.EventQueue $ 3.run(EventQueue.java:696)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:719)at   java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)     在   java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)     在   java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)   线程中的异常" AWT-EventQueue-0" java.lang.ClassCastException:   javax.swing.table.JTableHeader无法强制转换为javax.swing.JToolTip     在   javax.swing.plaf.synth.SynthToolTipUI.paint(SynthToolTipUI.java:179)     在   javax.swing.plaf.synth.SynthToolTipUI.update(SynthToolTipUI.java:141)     在javax.swing.JComponent.paintComponent(JComponent.java:778)at   javax.swing.JComponent.paint(JComponent.java:1054)at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JLayeredPane.paint(JLayeredPane.java:586)at at   javax.swing.JComponent.paintChildren(JComponent.java:887)at   javax.swing.JComponent.paint(JComponent.java:1063)at   javax.swing.JComponent.paintToOffscreen(JComponent.java:5222)at at   javax.swing.RepaintManager中的$ PaintManager.paintDoubleBuffered(RepaintManager.java:1572)     在   javax.swing.RepaintManager中的$ PaintManager.paint(RepaintManager.java:1495)     在javax.swing.RepaintManager.paint(RepaintManager.java:1265)at   javax.swing.JComponent._paintImmediately(JComponent.java:5170)at   javax.swing.JComponent.paintImmediately(JComponent.java:4981)at   javax.swing.RepaintManager $ 4.run(RepaintManager.java:824)at   javax.swing.RepaintManager $ 4.run(RepaintManager.java:807)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在   javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:807)     在   javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:782)     在   javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:731)     在javax.swing.RepaintManager.access $ 1300(RepaintManager.java:64)at   javax.swing.RepaintManager中的$ ProcessingRunnable.run(RepaintManager.java:1720)     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)     在java.awt.EventQueue.dispatchEventImpl(EventQueue.java:749)at   java.awt.EventQueue.access $ 500(EventQueue.java:97)at   java.awt.EventQueue $ 3.run(EventQueue.java:702)at   java.awt.EventQueue $ 3.run(EventQueue.java:696)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:719)at   java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)     在   java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)     在   java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     在java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

我用这一行添加了工具提示:

lblDrop.setToolTipText("testLabeltest");

这是什么意思?

感谢您的帮助:)

0 个答案:

没有答案