I am trying to add a background image to my applet, but don't know how to add.
Here is my code.
public class SAMmain extends JApplet{
public JMenuBar mbar=new JMenuBar();
public JMenu newStudent,viewtudent,markAttendence;
public void init() {
setSize(1366, 768);
setJMenuBar(mbar);
newStudent= new JMenu("New Student ");
mbar.add(newStudent);
viewtudent= new JMenu("View student");
mbar.add(viewtudent);
markAttendence= new JMenu("Mark Attendence");
mbar.add(markAttendence);
}
public void start() {
}
public void stop() {
}
}
You can use paint
function
public void paint(Graphics g) {
ImageIcon i = new ImageIcon("path");
g.drawImage(i.getImage(), x, y, this);
}
and dont forget to import import javax.swing.ImageIcon;