JLabel constructor can either take Icon,String or both.JLabel is used to display String text or icon to the user. Related Articles: ...
JLabel constructor can either take Icon,String or both.JLabel is used to display String text or icon to the user.
Related Articles:
Creating a JLabel With Icon Example
[import javax.swing.JLabel;
import javax.swing.ImageIcon; import javax.swing.Icon; import javax.swing.JTextField; import javax.swing.JFrame; public class JLabelExample extends JFrame{ JLabelExample() { super("JLabel Example"); Icon icon=new ImageIcon ("C:\\Users\\acer\\Downloads\\download.gif"); JLabel label=new JLabel(icon); label.setBounds(0,0,600, 600); add(label); setSize(600,600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(null); setVisible(true); } public static void main(String args[]) { new JLabelExample(); }
}]