项目是关于视频监控的,在预览视频的时候报错了,以前没有遇到过,错误如下:
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)
真没见过,不过很少做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外的组件了吗?之前这没用没问题,现在有问题了?这个是个鼠标事件啊,之前是不是没用到过鼠标事件?混用会引起这个问题吗
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。