Bug 198434 - JLayer support
JLayer support
Status: NEW
Product: guibuilder
Classification: Unclassified
Component: Code
All All
: P3 with 5 votes (vote)
Assigned To: issues@guibuilder
Depends on:
  Show dependency treegraph
Reported: 2011-05-08 15:52 UTC by Jan Stola
Modified: 2015-02-18 21:58 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Jan Stola 2011-05-08 15:52:11 UTC
JLayer is a new Swing component in JDK 7. NetBeans GUI Builder should provide layout support for this component similar to the one provided for JScrollPane, i.e., it should allow to DnD component onto JLayer to set JLayer's 'view' property.
Comment 1 vanja.dardic 2011-07-08 16:33:22 UTC
Hi. Will this feature be available in 7.0.1 version?
Comment 2 Petr Somol 2011-07-11 07:05:14 UTC
No, it is planned for 7.1.
Comment 3 mclaborn 2013-01-08 16:20:59 UTC
What's the status of this? NB 7.1 has been out for a while.
Comment 4 Petr Somol 2013-01-14 15:15:28 UTC
unfortunately the priorities kept being targeted elsewhere till now. the next round of planning is coming nearer so this issue will be reviewed again, but no details can be stated yet
Comment 5 arthurgregorio 2013-09-16 22:44:49 UTC
any update on this request?
Comment 6 arittner 2014-03-27 18:33:46 UTC
Now we at NetBeans 8 and Java 8. Any updates?
Comment 7 arittner 2014-05-05 10:23:47 UTC
I've played around with different workarounds to add JLayer to my GUI components, created with the form builder. It's a mess. Really.

It's (IMHO) impossible to wrap JLayer around GUI components with the customizer. pre-Init/post-Init and pre-Adding are useless points to wrap JLayer.

Another solution is to change all the components after initComponents (peek the component, wrap a JLayer, remove it from the container and add the JLayer at the same position with the same layout-constraints)*. But this doesn't work with all Layouts and needs different implementations (it works for: GroupLayout uses replace, GridBagLayout works with remove/add and peeking the GrindBagContraint from the LayoutManager; it doesn't work for AbsoluteLayout or other LayoutManager without the getConstraints-Method). 

Changing the Components after initComponents is very time consuming and a "heavy-listener-calling" workaround. Not very nice.

Please add a support for JLayer and LayerUI. We are now at Java8 and JLayer is introduced with 1.7. It's time to add this feature :-)

*) Here a sample (for all other poor developers who have already tried it):

  public JLayer installJLayer(JComponent view, LayerUI layerUI) {
    if ( layerUI == null ) {
      throw new NullPointerException ("Layer UI can't be null");
    JPanel parent = (JPanel) view.getParent();
    JLayer layer = new JLayer(view, layerUI);
    if ( parent != null ) {
      LayoutManager layout = parent.getLayout();
      if (layout instanceof GroupLayout) { 
        // Free Design
        ((GroupLayout) layout).replace(view, layer);
        layer.setView(view); // replace removes the view from JLayer
        return layer;
      } else if (layout instanceof GridBagLayout) {
        GridBagLayout gbl = (GridBagLayout) layout;
        GridBagConstraints gbc = gbl.getConstraints(view);
        for (int i = 0; i < parent.getComponentCount(); i++) {
          if (parent.getComponent(i) == view) {
            parent.add(layer, gbc, i);
            layer.setView(view); // parent.remove kills the view from JLayer
            return layer;
      // } else if {{ // Other LayoutManager with .getConstraints(view)
        // Implement, if u want...
      } else if ( layout == null ) {
        // Null-Layout
        for (int i = 0; i < parent.getComponentCount(); i++) {
          if (parent.getComponent(i) == view) {
            parent.add(layer, i);
            layer.setView(view); // parent.remove kills the view from JLayer
            return layer;
        return layer;
      throw new IllegalStateException("JLayer replace support is not available for " + layout.getClass().getName());
    } else {
      return layer;
Comment 8 mclaborn 2014-05-05 13:22:17 UTC
@arittner - very well put!

Agree with everything you said.  It is past time for this feature.
Comment 9 davidcbcs 2015-02-18 21:58:04 UTC
I agree with arittner.  Any updates on when this will be updated?

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