I have a Java Swing application. I want to insert a JLabel with png image as background and I want insert another JLabel at the center of this image. So I have build this code:
ImageIcon icon = new ImageIcon(getClass().getResource("/resources/cornometro_white.png"));
labelSfondoTimer = new JLabel(icon);
labelTempoGara = new JLabel();
labelTempoGara.text("pippo");
GridBagConstraints GBC2 = new GridBagConstraints();
Container CR2 = new Container();
GridBagLayout GBL2 = new GridBagLayout();
CR2.setComponentOrientation(ComponentOrientation.UNKNOWN);
CR2.setLayout(GBL2);
labelSfondoTimer.add(CR2);
GBC2 = new GridBagConstraints();
CR2.add(labelTempoGara);
GBC2.gridx=2;
GBC2.gridy=0;
GBC2.anchor= GridBagConstraints.CENTER;
GBL2.setConstraints(labelTempoGara,GBC2);
With this code, I can see the image on the screen but I can't see the secondo Label with text "pippo"
I have try also to insert this code:
labelSfondoTimer.setObaque(true); but not works.