Insert image to java application
Code:
URL image = main.class.getResource("your image url here");
// Image must be .jpg, gif, png.
// main.class.getResource --> "main is main function class in your application"
Add image to JLabel:
JLabel label = new JLabel(new ImageIcon(image);
Add image to JButton:
JButton label = new JButton(new ImageIcon(image);
The same for another component in Swing.
No comments yet