i wrote very simple code to display an icon of the grapes but still the code doesn't show me anything
here is my code
import javax.swing.*;
import java.awt.*;
public class Code {
ImageIcon ii = new ImageIcon("image/grapes2.jpg");
JLabel label = new JLabel("Grapes", ii, SwingConstants.CENTER);
JFrame frame = new JFrame("ImageIcon");
public void ui(){
label.setHorizontalTextPosition(SwingConstants.CENTER);
label.setVerticalTextPosition(SwingConstants.BOTTOM);
label.setIconTextGap(5);
label.setOpaque(true);
label.setBackground(Color.GRAY);
frame.setSize(2300,2300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(label);
}
}