如题,
请高手帮帮忙,自己java还在学习中...
代码就是这些:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class buttonrun implements ActionListener {
public buttonrun() {
}
Button b= new Button("yes");
b.addActionListener(this); -------->老是出错说这句需要标识符,为什么呢?我实在想不通,希望高手能够指点一下!
public void actionPerformed(ActionEvent e)
{ try{
Runtime.getRuntime().exec("C:\\Tomcat\\apache-tomcat-5.5.27\\apache-tomcat-5.5.27\\webapps\\gamefiles\\claaaa.exe ");
}
catch(Exception e)
{
}
}
public static void main(String []args)
{
buttonrun a =new buttonrun();
a.actionPerformed();
}
}还有就是程序里面写的对吗?我的想法是:这是JSP里的一个javabean,通过点击一个按钮,实现调用一个外部程序的作用
我的JSP页面上有一个按钮,通过这个按钮调用这个bean里的方法,我该怎么写好呢?是写在onclink里吗?希望大家能指点我一下,万分感谢!
<input name="button1" type="button" value="gameshow" onclick="??"/>
请高手帮帮忙,自己java还在学习中...
代码就是这些:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class buttonrun implements ActionListener {
public buttonrun() {
}
Button b= new Button("yes");
b.addActionListener(this); -------->老是出错说这句需要标识符,为什么呢?我实在想不通,希望高手能够指点一下!
public void actionPerformed(ActionEvent e)
{ try{
Runtime.getRuntime().exec("C:\\Tomcat\\apache-tomcat-5.5.27\\apache-tomcat-5.5.27\\webapps\\gamefiles\\claaaa.exe ");
}
catch(Exception e)
{
}
}
public static void main(String []args)
{
buttonrun a =new buttonrun();
a.actionPerformed();
}
}还有就是程序里面写的对吗?我的想法是:这是JSP里的一个javabean,通过点击一个按钮,实现调用一个外部程序的作用
我的JSP页面上有一个按钮,通过这个按钮调用这个bean里的方法,我该怎么写好呢?是写在onclink里吗?希望大家能指点我一下,万分感谢!
<input name="button1" type="button" value="gameshow" onclick="??"/>
b.addActionListener(this); -------->老是出错说这句需要标识符,为什么呢?我实在想不通,希望高手能够指点一下!
这句不能写到类体中,类体中只能包含变量声明与方法.程序语句需要写到方法体里.
这是个方法 你要写到方法体里面 比如
public void test()
{
Button b= new Button("yes");
b.addActionListener(this);
}
还有就是我还有后半个问题,以上的是JSP里的一个javabean,我想通过点击一个按钮,实现调用一个外部程序的作用 。
我的JSP页面上有一个按钮,通过这个按钮调用这个bean里的方法,我该怎么写好呢?是写在onclink里吗?希望大家能指点我一下,万分感谢!
<input name="button1" type="button" value="gameshow" onclick="??"/>