简体   繁体   English

在NetBeans GUI生成器设计的面板上绘图吗?

[英]Drawing on NetBeans GUI-builder designed panels?

I transferred a GUI I made with Netbeans GUI-builder to Eclipse. 我将用Netbeans GUI-builder制作的GUI转移到Eclipse。 I am wondering if I this scary-looking message the GUI-builder puts in the code is still relevant: 我想知道GUI生成器在代码中输入的这个看起来很恐怖的消息是否仍然有用:

  * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

I believe that the "Form Editor" can't "regenerate" the content since the code is no longer in NetBeans but I am not completely sure that the "Form Editor" isn't something that is brought along with the code (like in an import?). 我相信“表单编辑器”无法“重新生成”内容,因为该代码不再存在于NetBeans中,但是我不能完全确定“表单编辑器”不是随代码一起提供的(例如进口?)。

Thank you for your time. 感谢您的时间。

The message is no longer relevant as you are now within a new ide Eclipse and no longer Netbeans, the editor fold... is used within netbeans to help the ide detect regions to fold within the code. 该消息不再相关,因为您现在位于新的ide Eclipse中并且不再是Netbeans,在netbeans中使用了fold ...编辑器来帮助ide检测代码中折叠的区域。 However note that as you can tamper with comments and the code fold xml, its important you avoid tampering with the code generated by netbeans (unless you are sure of what you are doing) to avoid unpredictable behavior in the GUI. 但是请注意,由于您可以篡改注释和代码折叠xml,因此重要的是避免篡改netbeans生成的代码(除非您确定自己在做什么),以避免在GUI中发生不可预测的行为。 The file is now seen as a regular java file within eclipse. 现在,该文件被视为Eclipse中的常规Java文件。

Hope this helps, Good luck! 希望这有帮助,祝你好运!

That comment is no longer relevant because you're no longer using that file with the Form Editor plugin; 该注释不再相关,因为您不再将其与Form Editor插件一起使用。 now it's just like any other Java file you've got. 现在,就像您拥有的任何其他Java文件一样。

The Form Editor isn't brought along with the code, but instead it generates Java code for you based on the GUI that you create. 表单编辑器不随代码一起提供,而是基于您创建的GUI为您生成Java代码。

The plugin likely generates an instance initialization block like the following: 该插件可能会生成一个实例初始化块,如下所示:

{
    initComponents();
}

It uses an instance initialization block because that means that it will be executed regardless of which constructor is called, thus guaranteeing that initComponents() will happen. 它使用实例初始化块,因为这意味着无论调用哪个构造函数都将执行它,从而保证了initComponents()会发生。 The other part of that comment refers to the fact that the plugin specifically generates the initComponents() method based on external data, likely an XML file. 该注释的另一部分涉及以下事实:该插件专门基于外部数据(可能是XML文件initComponents()生成initComponents()方法。 If you modify that method by hand, it will be deleted and regenerated on the next compile. 如果您手动修改该方法,它将被删除并在下一次编译时重新生成。

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

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