简体   繁体   English

在NetBeans中将面板添加到JFrame时出错

[英]Error adding Panel to JFrame in NetBeans

So I made a JPanel and a JFrame using the Design functions in NetBeans and when I try to drag the panel onto the JFrame, I get the error "The component cannot be instantiated. Please make sure it is a JavaBeans component." 因此,我使用NetBeans中的“设计”功能制作了一个JPanel和一个JFrame,当我尝试将面板拖到JFrame上时,出现错误“无法实例化该组件。请确保它是JavaBeans组件。”

What I did was create an empty Frame and then create the Panel and put it all together using the panels, buttons, and text fields. 我要做的是创建一个空框架,然后创建面板,并使用面板,按钮和文本字段将其放在一起。 I didn't modify the source code or anything. 我没有修改源代码或任何东西。 Is there some kind of code I need to add into the panel to make it work with the JFrame? 我需要在面板中添加某种代码以使其与JFrame一起使用吗? Or perhaps I missed a step in the design tab? 还是我错过了设计标签中的步骤? I've included a picture that shows exactly what it is I made. 我附上一张图片,准确显示了我的作品。

jpanel 的JPanel

Clean and build the project (and sub projects as required). 清理并构建项目(以及所需的子项目)。

If you're using Netbeans 7+, you can check the messages.log found in C:/Users/{username}/AppData/Roaming/NetBeans/{Netbeans version}/var/log and check for the exception that caused the problem. 如果您使用的是Netbeans 7+,则可以检查在C:/Users/{username}/AppData/Roaming/NetBeans/{Netbeans version}/var/log找到的messages.log ,并检查导致问题的异常。

I think the new 7.2 beta reports the problems to the user now (thankfully). 我认为新的7.2测试版现在(感谢)向用户报告了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM