0
I’m in trouble, so I can add a JLabel
with a word before an icon. I put the image in my package, and passed the way, the problem is that the label is concatenating with the String
(the word I put before), and instead of leaving the word + the image, it shows me the path of the image.
What would be the right way to do it ?
what I did:
package teste;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class LabelIcone extends JFrame {
public LabelIcone() {
setSize(400, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
ImageIcon icone = new ImageIcon(getClass().getResource("/imagens/icone.png"));
JLabel label = new JLabel("Teste" + icone);
add(label);
}
public static void main(String[] args) {
LabelIcone lbIc = new LabelIcone();
lbIc.setVisible(true);
}
}
this way there, you are not pasting a word/text before, only the icon I can put. Thanks more for responding !
– JavaTech