I’m just starting in Java and i’m stuck on something really annoying.
I’m using NetBeans IDE and i’m building a JFrame using drag and drop. I added two labels to my frame and renamed them (using the WYSIWYG interface designer).
Now I want to go in the code and change the names of the labels but they are not visible (in the code). Any idea why ?
(I usually program in C# and with the designer the label are automatically visible in the code)
Update :
I get the following error when I try to refer to the label.

In the code they are declared in the
initComponents()method generated by Netbeans.If I understood you correctly, you are just looking for the JLabel variable names? If so, this is the place they would be located — not sure if Netbeans allows you to change anything in the
initComponents()method though. You might have to do it in the GUI editor by right clicking the label and setting the properties as you like there.EDIT
That is happening because you are likely doing this in main which is a static method. I would personally create a JPanel for the labels. For example, lets say the labels are ‘Titles’. So I would create a TitlePanel class to hold these JLabels (with whatever layout you’d like).
This way you can reference the class from your main and add it like so:
On another note though, it would be wiser to learn swing via the language rather than the GUI builder simply because you might not always want to use Netbeans as the IDE but may change your preference in the future.