Default code Generation settings not for Actions

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Default code Generation settings not for Actions

Postby chrisR » Mon Jul 27, 2009 7:08 am

After adding a new (External)Action Swing Designer generates a final field:

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 :?:
chrisR
 
Posts: 19
Joined: Thu Jul 23, 2009 5:07 am

Re: Default code Generation settings not for Actions

Postby Eric Clayberg » Tue Jul 28, 2009 6:46 am

The latest Swing Designer v7.1 build now supports lazy code generation for Actions.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Default code Generation settings not for Actions

Postby chrisR » Tue Jul 28, 2009 8:09 am

Thanks Eric Clayberg,

it works.

chrisR
chrisR
 
Posts: 19
Joined: Thu Jul 23, 2009 5:07 am

Re: Default code Generation settings not for Actions

Postby Eric Clayberg » Tue Jul 28, 2009 9:19 am

Good. I'm glad it now works the way you would like.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest