Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make WindowBuilder create fields that are not nested in Eclipse, Java

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();
}
like image 638
Cole Canning Avatar asked Aug 03 '12 20:08

Cole Canning


1 Answers

There's a button to convert an element from "local to field".

Convert

If you want all components to be fields by default: Windows -> Preferences -> WindowBuilder -> Swing -> Code Generation -> Find "Variable generation" and select the "Field" tab.

like image 97
Chris911 Avatar answered Oct 01 '22 00:10

Chris911