• netbeans拖控件做的界面出现“窗体损坏”的解决办法


    问题呈现:netbeans提示窗体损坏,只能以只读方式呈现空间,没法再直接修改控件。

    问题原因:其实就是自动生成initComponent和action方法等的代码里,那部分标记属性设置、方法开始、方法结束的绿色的字体的标记代码缺失造成的。

    解决办法:找原先的文件,对比,把绿色的标记性代码补全即可。

     

    文档中,详细问题表述和解决办法如下(网址 http://wiki.netbeans.org/FormGuardedBlockError):

    FormGuardedBlockError

    Guarded blocks inside form java source file

    What you do in the Form Editor is stored in an XML file with the extension .form with the same name as your class. This XML is used to generate the code that instantiates and initializes your visual components. This code appears in a method called InitComponents(), which appears in a read-only guarded block in the editor (blue background). Also declaration of form component variables are generated into guarded block.


    Close the form inside IDE and check the content of the form java class file inside plain text editor (notepad, vi, ...). Guarded block starts with //GEN-BEGIN:name and ends with //GEN-END:name. Form editor generates java code between these paired tags and if editor is not able to find these tags, form will be opened only in read-only mode.

    public class NewJFrame1 extends javax.swing.JFrame {
    
        public NewJFrame1() {
            initComponents();
        }
    
        ...
    
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {
    
            ...
    
        }// </editor-fold>//GEN-END:initComponents
    
    
        ....
    
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JButton jButton1;
    
        ....
    
        private javax.swing.JButton jButton2;
        // End of variables declaration//GEN-END:variables
    
    }
    
  • 相关阅读:
    过滤器--起步阶段
    常用指令-起步阶段
    模型和控制器-起步阶段
    指令介绍-起步阶段
    AngularJS简介-起步阶段
    c++之helloworld与命名空间
    c++ 之重要性
    一个没曾摸透的程序
    linux中什么是文件结构体?
    很全的linux网络编程技巧
  • 原文地址:https://www.cnblogs.com/liuyuanyuanGOGO/p/3070442.html
Copyright © 2020-2023  润新知