将背景图像添加到applet框架中 [英] Add background image into applet frame
本文介绍了将背景图像添加到applet框架中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试向我的applet添加背景图片,但不知道如何添加。
I am trying to add a background image to my applet, but don't know how to add.
这是我的代码。
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() {
}
}
推荐答案
您可以使用 paint
函数
public void paint(Graphics g) {
ImageIcon i = new ImageIcon("path");
g.drawImage(i.getImage(), x, y, this);
}
并且不要忘记导入 import javax.swing。 ImageIcon;
这篇关于将背景图像添加到applet框架中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文