Netbeans GUI 生成器私人成员
我有一个现有项目,我决定在 Netbeans 中为其创建一个 GUI。我遇到的问题是,我拖放的每个组件在源代码中都是私有的并且不可修改。我必须为所有东西创建吸气剂吗?
我主要只需要解决这个问题才能附加到 TextArea。
先感谢您
I have an existing project for which i have decided to create a GUI for in Netbeans. The problem I am encountering is the fact that every component that i drag-and-drop is private in the source and is unmodifiable. Must i create getters for everything?
I mainly just need this problem resolved for appending to the TextArea.
Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想全局更改它,请转到选项对话框,然后选择其他,然后选择 gui 构建器选项卡。您可以在那里配置默认修饰符。
If you want to change that globally, go to the options dialog, then select miscellaneous, and pick the gui builder tab. You can configure the default modifier there.
通过右键单击“检查器”面板中的组件,您可以影响生成的代码,即使它位于编辑器文件夹中且不可直接编辑。例如,右键单击
JList
并编辑Properties > model
添加文本条目;右键单击代码>发布创建代码
以添加影响选择模型的代码片段:检查编辑器文件夹中的代码以查看生成的更改。
另请参阅GUI 构建简介。
By right clicking on a component in the
Inspector
panel, you can influence the generated code, even though it is in an editor-fold and not directly editable. For example, right click on aJList
and edit theProperties > model
to add text entries; right click onCode > Post Creation Code
to add a code snippet affecting the selection model:Examine the code in the editor-fold to see the generated changes.
See also Introduction to GUI Building.
您应该在代码中看到一些标签,这些标签与变量区域的开始和结束有关。通常有 2 组不同的标签,当您使用表单生成器修改 gui 时,这些标签之间的任何代码都会重新生成。
您可以在这些标签之外编写自己的代码,即使在进行更改后它也应该保留。如果您需要从另一个类更新对象,getter 和 setter 是一个好主意。我之前已经对一些文本区域做过这样的事情,我有一个实用程序类更新其中的文本。
You should see some tags in the code, something to do with begin and end of variable area. Usually there are 2 different sets of tags, any code between those tags will regenerate when you modify the gui with the form builder.
You can write your own code outside of those tags and it should remain even after you make changes. Getters and setters are a good idea if you need to update your object from another class. I've done that before with some text areas where I had a utility class update the text in it.