如何使WindowBuilder创建不嵌套在Eclipse,Java中的字段 [英] How to make WindowBuilder create fields that are not nested in Eclipse, Java
问题描述
当我创建一个按钮或菜单(或任何东西)时,它会创建嵌套在构造函数内的字段。有没有办法使它们的字段,然后在构造函数中初始化,所以我可以在构造函数之外使用它们?谢谢。
ie:FROM
public GUIFrame()
JMenuBar menuBar = new JMenuBar();
}
TO
public JMenuBar menubar;
public GUIFrame(){
menuBar = new JMenuBar();
}
有一个按钮可以转换元素从本地到字段。
如果您希望所有组件默认为字段:Windows - >首选项 - > WindowBuilder - > Swing - >代码生成 - >查找变量生成,然后选择 标签。
I am using WindowBuilder for Eclipse Java.
When I make a Button or a Menu (or anything), it creates the fields nested inside of the constructor. Is there any way to make them fields and then initialized in the constructor so I can use them outside of the constructor? Thank you.
ie: FROM
public GUIFrame() {
JMenuBar menuBar = new JMenuBar();
}
TO
public JMenuBar menubar;
public GUIFrame() {
menuBar = new JMenuBar();
}
There's a button to convert an element from "local to field".
If you want all components to be fields by default: Windows -> Preferences -> WindowBuilder -> Swing -> Code Generation -> Find "Variable generation" and select the "Field" tab.
这篇关于如何使WindowBuilder创建不嵌套在Eclipse,Java中的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!