How can I set the image? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I set the image?

I tried to set the image through setBounds and setSize but the image is not correctly set , the image is visible and the size is by default, how I set the image correctly by own? https://code.sololearn.com/cf7ZE5g5h3dp/?ref=app

2nd Nov 2022, 11:46 AM
Sakshi
Sakshi - avatar
4 Answers
+ 1
I would say you need to use createImageIcon() ImageIcon i1 = createImageIcon("laughing.png"); https://docs.oracle.com/javase/tutorial/uiswing/components/icon.html
2nd Nov 2022, 3:23 PM
Denise Roßberg
Denise Roßberg - avatar
2nd Nov 2022, 3:31 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
I try this one, Thank you 😊
2nd Nov 2022, 3:33 PM
Sakshi
Sakshi - avatar
0
But how I set the image because I make project guess emoji song then I put the multiple images so it's necessary for me to set the image size.
2nd Nov 2022, 3:27 PM
Sakshi
Sakshi - avatar