Load Image Path JLabel using Java is one of the file formats that can help your designs more attractive. There are many types of image that we can use in Web or Desktop applications, the jpeg, gif, png, and bitmap extensions.
This tutorial entitled “Load Image from Path to JLabel” will help you to understand on how to load an image from path to a jLabel element. This tutorial will use jLabel, jTextField, and jButton to complete this tutorial.
Load Image Path JLabel Using Java Steps
- Create/Add a new jFrame Form in your project
2. Design your jFrame form just look like the image below.
3. Add the following imports above your class to access the library for Image, and Icon.
import java.awt.Image; import javax.swing.ImageIcon;
4. Double click your button and add the following codes below
ImageIcon imgThisImg = new ImageIcon(new ImageIcon(jTextField1.getText()) .getImage().getScaledInstance(360, 171, Image.SCALE_DEFAULT)); jLabel1.setIcon(imgThisImg);
jTextField1 (Image path)
360 (Image Width)
171 (Image Height)
jLabel1 (Display the Image)
5. Run your program and it should look like the image below.
About The Load Image from Path to JLabel
Project Name: | Load Image from Path to JLabel |
Language/s Used: | JAVA |
Database: | None |
Type: | Desktop Application |
Developer: | IT SOURCECODE |
Updates: | 0 |
If you have any questions or suggestion about Load Image Path JLabel using Java, Please feel free to contact us at our contact page.