public class VC extends JApplet implements ActionListener {
private JButton save = null;
public void init() {
//添加按钮
save = new JButton(" 拍 照 ");
//增加事件
save.addActionListener(this);
//添加面板
Panel panel1 = new Panel(new FlowLayout());
panel1.add(save, BorderLayout.SOUTH);
add(panel1, BorderLayout.CENTER);
}
/**
*
* 点击拍照
*/
public void actionPerformed(ActionEvent e) {
System.out.println("响应事件");
}
}
这段程序为什么签到jsp中就不好用了呢?求高人指点
事件处理的方法是单击按钮保存图片的.用main运行好用. 签到页面无效了.
public void actionPerformed(ActionEvent e) {
FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
buf = fgc.grabFrame();
btoi = new BufferToImage((VideoFormat) buf.getFormat());
img = btoi.createImage(buf);
BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = bi.createGraphics();
g2.drawImage(img, null, null);
<%@page language="java" contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="wang.connectDB"/>
< ......