I am using eclipse and search around for tutorials but none of them helped me much because I would get errors if I tried those functions. I just wanna know what I am doing wrong or what should I use to get the code working. I Picture below is the final product, I just wanna add a picture and work towards adding text next. So for now All i want to know is adding an image using GUI features. Also, I tried the code below and doesn't show an image for some reason. Also I would like to know what i am doing wrong and how i can correct it.
package Lab09Exercises;
import javax.swing.*;
public class Lab09Excercise extends JFrame {
JPanel jp = new JPanel();
JButton jb = new JButton();
public Lab09Excercise() {
setTitle("Excercise2");
setVisible(true);
setSize(400,600);
setDefaultCloseOperation(EXIT_ON_CLOSE);
jb.setIcon(new ImageIcon("advertising.png"));
jp.add(jb);
add(jb);
validate();
}
public static void main(String[] args) {
Lab09Excercise a = new Lab09Excercise();
}
}
[![the image is the result i want to get but i just wanana know how do add an image first before I can add rest of the components][1]][1]
[1]: https://i.stack.imgur.com/QsvFp.png