FaqFormNoSwingLayout

Can I design my GUI without using the swing-layout library?

Yes.

Though the "free design" mode requiring the swing-layout library is offered by default for newly created forms, you can avoid using it. This means you need to use a standard layout manager for each visual container. Do this only if you need to deploy just with standard JDK classes (for pre-Java 6 version) and if you are willing to configure all the layout managers' settings.

  1. Whenever you create a new form, set its layout immediately to the desired layout manager:
  • right click the form in the designer, go to the Layout menu and choose some layout manager (e.g. GridBagLayout).
  1. Save, close, and open the form again (or hit Ctrl-R).
  2. From now the "free design" mode will not be offered for this form, each new container added will have its default layout manager.

To ease this a bit, you can save the form from step 1 as a template and next time create new forms from it:

  1. Right-click the created file in Projects explorer.
  2. Choose 'Save As Template...' and then 'Java GUI Forms' category.
  3. Create new forms as usual via the New wizard - just select your template.

Before you go to distribute the application, test that all your projects don't use the swing-layout library:

  1. Go to the project properties, Libraries node, and make sure there is no Swing Layout Extensions library (remove it).
  2. Then clean and build the project.
  3. If it builds fine, you can be sure it uses just standard JDK classes.

  Applies to: NetBeans 5.0, 5.5, 6.0
  Platforms: All
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo