How to use a Master/Detail panel as a component in other GUI forms? I.e. how to instantiate it inside NetBeans?

Master/Detail Panel itself cannot be instantiated and inserted in another form class. The reason is that it is not possible to instantiate and use entity manager in the IDE because the IDE itself is not set up as standalone JPA application.

Example how to set Master/Detail Panel as Bean: java.beans.Beans.isDesignTime() method will help you to do that. This method can be used by any bean (e.g. by master/detail panel in your case) to find out whether the bean is inside the IDE or not. Hence, you should modify your template not to do any JPA stuff in the IDE.

For example, change the following line in the constructor:



    if (!Beans.isDesignTime()) {

You also have to modify the initialization of 'entityManager' field:

  1. Select entityManager in Inspector window (it is under Other components).
  2. Invoke Customize Code action.
  3. Enter 'if (!Beans.isDesignTime()) {' before the (guarded) default code of the GUI builder.
  4. Enter '}' below the default code generated by the GUI builder.
  5. Make sure that the last combo-box on the left is set to 'post-create'.
  6. Press OK.

Modify the initialization of 'query' in the same way.

Modify the initialization of 'list' in the similar way e.g. from

   list = ... <default code> 


    if (Beans.isDesignTime()) {
        list = java.util.Collections.emptyList();
    } else {
        list = ... <default code>

  Applies to: NetBeans 6.x
  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