开发者社区> 问答> 正文

java.lang.IllegalArgumentException: Comp?报错

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

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)



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

展开
收起
爱吃鱼的程序员 2020-06-22 11:29:29 781 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

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

    2020-06-22 11:29:46
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载