javaimageswingnetbeansgui-builder

Put label on a label in netbeans GUI builder


Trying desperately to put a label over another label in netbeans because the one label is acting as the background image and I want the label in the foreground to have a different image.

Every time i drag another label on top, the JFrame gets bigger and the label tries to slot down the side.

Here is what I've got (I want the label where the red circle in the middle is not on the right down the side):

:


Solution

  • If you want to put one component on another, then you can use Layered Panes. A layered panel will let you specify that some child components should be layered above other child components.

    enter image description here

    Update:

    An example:

    JLayeredPane pane = new JLayeredPane();
    
    JLabel lbOne= new JLabel("Label one");
    JLabel lbTwo = new JLabel("Label two");
    
    pane.add(lbOne, 0);
    pane.add(lbTwo , 1);