Enclose In option greyed out in Netbeans GUI builder

1.6k Views Asked by At

Building a Java GUI application using Netbeans IDE. I have created a JPanel in it. After adding a lot of fields, I want to also add a JscrollPane to it. I have found that if we right click on the pane we have an option to Enclose it in a container that can be Scroll pane or Split pane etc.

The problem is, that the enclosed button is greyed out when I right click on the panel. How should i fix this ?

1

There are 1 best solutions below

0
On

I had the same issue. After experimentation, it appears you can only use Enclose In if the Layout is set to Free Design.

However, an alternative method I discovered to accomplish the same thing is to create the empty JPanel and the components you want inside it, all at the same level in the TopComponent. Then drag and drop the components you want into the JPanel, using the Navigator window that shows the component hierarchy.

For example, here I've created a JPanel and a JRadioButton as siblings, and then I drag and drop the JRadioButton inside the JPanel, so that the JPanel is the parent.

JRadioButton and JPanel are siblings

Result:

now JRadioButton is a child of the JPanel