can we add any image in java program ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 10

can we add any image in java program ?

think i want to add a image in java program like those done in html by <img> tag. Is their any syntax for addition of image in java.

17th Feb 2019, 4:43 AM
suman Kayal
suman Kayal - avatar
4 Answers
+ 7
Before adding u need to have a GUI (like JFrame). Then add the image with a JLabel YOURGUI.add(new JLabel(new ImageIcon("PATH_TO_IMG")));
17th Feb 2019, 5:47 AM
Seniru
Seniru - avatar
+ 11
For this, u need to use any graphic library of java.
17th Feb 2019, 5:03 AM
Arushi Singhania
Arushi Singhania - avatar
+ 2
suman Kayal Use an IDE like NetBeans, Eclipse in ur PC. It is quite possible to add pics in Java . U need a GUI platform for example JFrame, JPanel etc... For this u need a IDE Download NetBeans or Eclipse
17th Feb 2019, 11:55 AM
Arpan Bhattacharya
Arpan Bhattacharya - avatar
+ 1
you need a GUI like swing to add an image, using JLabel, you can add icon on it and resize
17th Feb 2019, 6:44 AM
John Nehry C. Dedoro
John Nehry C. Dedoro - avatar