FaqFormChangingType

Can I change the type of already created forms?

This requires to change the form superclass. It is not supported directly, but it can be achieved by the following steps. For example, we want to change a JFrame form to JPanel form:

  1. Open the JFrame form and remove everything incompatible with the target type (in our case remove windowClosing event, and also menubar if set, which cannot be used in JPanel).
  2. Save and close the form.
  3. Open just the java file in the Source view (use Edit action from context menu).
  4. Change the superclass to the desired class (javax.swing.JPanel).
  5. Save and close the java file.
  6. Open the form again — the code is regenerated for the new type automatically (in our case all getContentPane() calls disappear).
  7. Save the form and you are done.

  Applies to: All NetBeans versions
  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