- Code: Select all
private final SwingAction swingAction = new SwingAction();
protected JButton getBtn() {
if (btn == null) {
btn = new JButton("New button");
btn.setAction(swingAction);
}
return btn;
}
independent of the code generation settings of the Preferences.
Does Swing Designer support lazy initialization of Actions
- Code: Select all
protected SwingAction getSwingAction() {
if (swingAction == null) {
swingAction = new SwingAction();
}
return swingAction;
}
protected JButton getBtn() {
if (btn == null) {
btn = new JButton("New button");
btn.setAction(getSwingAction());
}
return btn;
}
How I customize Swing Designer to get a separate getXXX() Method with lazy Initialization