java.lang.IllegalArgumentException: Component must be heavyweight

影非弦 发布于 2014/03/18 09:53
阅读 1K+
收藏 0

项目是关于视频监控的,在预览视频的时候报错了,以前没有遇到过,错误如下:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Component must be heavyweight
	at com.sun.jna.Native.getComponentID(Native.java:151)
	at com.sun.jna.Native.getComponentPointer(Native.java:185)
	at vedioTest.MainVedio.jButtonYuLanActionPerformed(MainVedio.java:239)
	at vedioTest.MainVedio.access$000(MainVedio.java:27)
	at vedioTest.MainVedio$1.actionPerformed(MainVedio.java:93)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6267)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6032)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2478)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)



组件必须是重量级组件,这个错误提示不知道什么意思

加载中
0
红薯
红薯
真没见过,不过很少做gui应用,不太清楚
0
NealFeng
NealFeng
看不出来,可能是轻量级和重量级组件混用了。。。
影非弦
影非弦
回复 @NealFeng : 嗯,是的,这个需要heavyweight componet,我用的javax.swing.jPanel是light componet,改成awt的就可以了
NealFeng
NealFeng
回复 @影非弦 : 这个函数需要heavyweight component,https://jna.java.net/nonav/javadoc/com/sun/jna/Native.html#getComponentID(java.awt.Component),Jpanel是lightweight,所以报错了。我不懂JNA,你找找有没有方法实现你的功能吧。
影非弦
影非弦
回复 @NealFeng : //获取窗口句柄 HWND hwnd = new HWND(Native.getComponentPointer(jPanelVedio)); 调试的时候发现这一步报了这个错误
NealFeng
NealFeng
回复 @影非弦 : 可能吧。只是看到文档里轻量级和重量级的组件有些差异,混用估计出问题几率高吧。这个是用JNA调用了java外的组件了吗?之前这没用没问题,现在有问题了?这个是个鼠标事件啊,之前是不是没用到过鼠标事件?
影非弦
影非弦
混用会引起这个问题吗
返回顶部
顶部