1

I want to put Image on JButton or JLabel, but It doesn't appear on the program.

import javax.swing.*;

public class JButtonEx extends JFrame{

JButtonEx() {
    setSize(300,300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel(new ImageIcon("network/star.png"));
    add(label);
    setVisible(true);
}

public static void main(String[] args) {
    new JButtonEx();
}
}
Andrew Thompson
  • 166,747
  • 40
  • 210
  • 420

0 Answers0