+ 8

How to set image in java

30th Apr 2019, 12:00 PM
Abdul rahman;
Abdul rahman; - avatar
7 Antworten
+ 9
Sεηιrυ ραsαη Yes for static images . Although almost all components have icon property but only button and label shows properly
30th Apr 2019, 4:35 PM
Siddharth Golecha
Siddharth Golecha - avatar
+ 8
You can set image on Labels using JLabel and also on JButtons
30th Apr 2019, 4:16 PM
Siddharth Golecha
Siddharth Golecha - avatar
+ 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)
30th Apr 2019, 12:52 PM
Seniru
Seniru - avatar
+ 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 😊
30th Apr 2019, 4:25 PM
Seniru
Seniru - avatar
+ 1
I cant do it too
1st May 2019, 10:02 AM
Молоко Молоко
Молоко Молоко - avatar
0
What you name
2nd May 2019, 2:08 AM
Josue blancsaintcyr Saint cyr
Josue blancsaintcyr Saint cyr - avatar