[英]Netbeans GUI Builder: how to edit generated code
Im using Netbeans GUI Builder and I am adding a JTree to my form, as it does Netbeans is generating all the code for the JTree. 我正在使用Netbeans GUI Builder,并且正在向表单中添加JTree,因为Netbeans会为JTree生成所有代码。
What i want to know is, is there a way in Netbeans to add code to the generated code... like in the source view in the Generated Code
section it creates 我想知道的是,Netbeans中是否有一种方法可以将代码添加到生成的代码中...就像在它创建的“
Generated Code
部分的源代码视图中一样
jTree = new javax.swing.JTree();
i want to add populateJTree.addNodes(null, folder)
so it looks like 我想添加
populateJTree.addNodes(null, folder)
所以它看起来像
jTree = new javax.swing.JTree(populateJTree.addNodes(null, folder));
Is there a way of doing this 有没有办法做到这一点
i sorted it, if you go to the Properties
window for the JTree and the Code
section, you can add 我对它进行了排序,如果转到“ JTree”和“
Code
部分的Code
Properties
窗口,则可以添加
new javax.swing.JTree(populateJTree.addNodes(null, folder));
to the custom creation code part and it will create 到自定义创建代码部分,它将创建
jTree = new javax.swing.JTree(populateJTree.addNodes(null, folder));
Yes there is a way to add code. 是的,有一种添加代码的方法。 Just right click on the component (in this example it would be JTree) than choose "Customize code", select "custom creation" and you are good to go.
只需右键单击该组件(在此示例中为JTree),然后选择“定制代码”,选择“定制创建”即可。
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
and in the end of initComponents() method, remove // </editor-fold>//GEN-END:initComponents
@SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
,在initComponents()方法的最后,删除// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
and // End of variables declaration//GEN-END:variables
// Variables declaration - do not modify//GEN-BEGIN:variables
和// End of variables declaration//GEN-END:variables
see now you can edit the Generated code. 现在看到,您可以编辑生成的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.