Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:52:08+00:00 2026-06-11T05:52:08+00:00

Abstract : I’m looking for a way to configure Eclipse Window Builder’s code generator

  • 0

Abstract: I’m looking for a way to configure Eclipse Window Builder’s code generator to place its object references in the class body instead of locally in the initalize() method.

Detailed:

Window builder has a built in code generator/code analyzer which can generate GUI code from a ‘graphical form designer’ and vice versa. It is of great use to design GUIs quickly and learn how the various frameworks work in java (especially for java beginners). However, i am having trouble using the generated code in my design when moving towards more sophisticated GUI setups. The problem is that most of the generated code is being placed inside the initialize() method which makes the objects resident in the local scope and hard to get references to from the ‘outside’.

So far i’ve been copy/pasting the type declarations from the initialize() method into the class body manually as public to have access to them, but this seems somehow the wrong approach. It works fine as long as i don’t reorganize the GUI from within the Graphical Designer. In that case the code generator places it’s type declarations again in the initialize() method.

Automatically generated code looks like this:

   // AUTO-GENERATED CODE
   public class MyGUI {
      private void initialize() {
          // gui objects declared AND created in this scope by Window Builder
          JFrame frame = new JFrame();
          JPanel panel_1 = new JPanel();
          frame.getContentPane().add(panel_1);
    }
  }

What i would like is:

   public class MyGUI {
          // accessible from outside
          public Frame frame = null;
          public JPanel panel_1 = null;

       private void initialize() {
          // gui objects only created in this scope
          frame = new JFrame();
          panel_1 = new JPanel();
          frame.getContentPane().add(panel_1);
    }
  }

I’ve been looking in the documentation for a solution (scarce documentation on that), and also studied the various Window Builder preferences but no luck so far. There is the ‘data binding’ but it seems to implement MVC (bind the gui elements to a model) and quite a overkill.

Is there a design pattern i’m missing, or am i supposed to ‘fish’ the references out of the local scope of initialize() somehow ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:52:09+00:00Added an answer on June 11, 2026 at 5:52 am

    In the Preferences window, expand WindowBuilder and Swing (or SWT) and then expand Code Generation. There are options to declare variables locally, as class-level fields, and lazily initialized. You can also choose flat or block statements. There are some examples in the documentation under WindowBuilder Pro User Guide > Preferences > Swing of what to look for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a abstract factory implementation: public class FooFactory : IFooFactory { public IFoo Create(object
Abstract I am writing an application which has a few object caches. The way
abstract class Foo { private List<Object> container; private bool update; Foo Foo() { container
abstract class User { protected $content; // $content object will be assigned here }
public abstract class ExeCommand { private static object commandHandler; public static object CommandHandler {
Consider the following code: abstract class SomeClassX<T> { // blah } class SomeClassY: SomeClassX<int>
I have builder: public abstract class ScriptBuilder { public void buildScript() { this.commandList =
class ABC is an abstract base class. class X is its subclass. There's some
Code: abstract class Parent{ void changeChild(){ } } class Child1: Parent{ } class Child2:
public abstract class JsonElement extends Object A class representing an element of Json. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.