给按钮加监听啊。 JButton btn = new JButton("OK");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//你的程序入口
}
});
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//你的程序入口
}
});
解决方案 »
- 程序变换一下,新手高手都可以帮忙拿分啊! 进来就有人
- property.js ajax 表单提交的写法
- 有2个问题不懂,有点偏门,请高手来看看~~
- 求高手点拨一个“方法中的异常”处理方法...
- 初学者的问题:一个WebLogic7启动异常的问题。谢谢!
- 谁有jbuilder的注册码或注册文件
- 高分请教字符串编码问题
- 简单问题,请多指教。
- 为何出现这个错误:java.sql.SQLException: 对只读结果集的无效操作: updateString;code如下:
- java广泛运用于internet上,请大家推荐些好网站,用awt 或swing做的applet程序应用
- 你好,请问在sql语句中怎样获得access数据表中的最后插入的那条数据?在sql中如何将日期/时间类型的字段值只取日期?
- 如何进行地址传递
JButton实现ActionListener接口我是知道的
我不明白程序入口是什么意思,是不是main()函数
可我的main函数在我的一个class里面,怎么放到ActionPerformedli里面
public class TestP()
{
public static void main(String [] args)
{
TestPFrame frame = new TestPFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
JButton btn = new JButton("OK");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
TestPFrame frame = new TestPFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
});
Class cls = Class.forName("TestPFrame");
Method method = cls.getMethod("main", new Class[]{ String[].class });
method.invoke(cls, new Object[]{new String[0]});OK?
String[] arg = new String[0];
TestPFrame.main(arg);
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { yourclasstype yourinstance= new yourclass();
yourinstance.yourmethod(); }
}
geyf(我在学java):你说的我有一点疑问,我要加的“确定”键 是想放在我的main函数frame里的
内容窗阁中,此窗阁中还有其他的按钮,我现在不明白的是你的btn键是放在哪里的,好象少了在某个内容窗阁中的contentpane.add(btn);我再回去看看juhwali(华仔):你说的方法我还没见过,要回去查资料试试,:)
getContentPane().add(btn);