+ 8
How to set image in java
6 Answers
+ 9
SĪµĪ·Ī¹rĻ
ĻĪ±sĪ±Ī· Yes for static images .
Although almost all components have icon property but only button and label shows properly
+ 8
You can set image on Labels using JLabel
and also on JButtons
+ 4
The easiest way would be using a JLabel.
For example,
new JLabel(new ImageIcon(PATH_OF_THE_IMG));
https://docs.oracle.com/javase/7/docs/api/javax/swing/ImageIcon.html#ImageIcon(java.lang.String,%20java.lang.String)
https://docs.oracle.com/javase/7/docs/api/javax/swing/JLabel.html#JLabel(javax.swing.Icon)
+ 4
Siddharth Golecha actually on almost all Components that accepts an Icon class. But I think JLabel is the most correct option for just displaying images š
+ 1
I cant do it too
0
What you name