import java.awt.*;
import java.awt.event.ActionListener;
import java.util.EventListener;
import java.awt.ActiveEvent;
public class TestFrame implements ActionListener {
/**
* Method main
*
*
* @param args
*
*/
Frame f = new Frame("www.it315.org");
public static void main(String[] args) {
// TODO: Add your code here
Button but = new Button("退出");
TestFrame tf = new TestFrame();
tf.f.setSize(300,300);
tf.f.add(but);
but.addActionListener(this);
tf.f.setVisible(true);
//tf.f.addWindowListener(new MyWindowListener());
} /**
* Method actionPerformed
*
*
* @param e
*
*/
public void actionPerformed(ActionEvent e) {
// TODO: Add your code here
f.dispose();
System.exit(0);
}
}
为什么通不过,我觉的不应该有什么问题。请各位帮忙。?
import java.awt.event.ActionListener;
import java.util.EventListener;
import java.awt.ActiveEvent;
public class TestFrame implements ActionListener {
/**
* Method main
*
*
* @param args
*
*/
Frame f = new Frame("www.it315.org");
public static void main(String[] args) {
// TODO: Add your code here
Button but = new Button("退出");
TestFrame tf = new TestFrame();
tf.f.setSize(300,300);
tf.f.add(but);
but.addActionListener(this);
tf.f.setVisible(true);
//tf.f.addWindowListener(new MyWindowListener());
} /**
* Method actionPerformed
*
*
* @param e
*
*/
public void actionPerformed(ActionEvent e) {
// TODO: Add your code here
f.dispose();
System.exit(0);
}
}
为什么通不过,我觉的不应该有什么问题。请各位帮忙。?
解决方案 »
- Java NIO 一直接收OP_ACCEPT的问题
- java如何模拟IP请求
- socket 连接状态判断
- (版主请看)本人组团队开发个公共的订餐系统,有人愿意提供cvs或者vss服务器吗?那个彩票系统就是我做的一个demo.
- 急!!求一个多文件同时上传的例子!!
- 请教学JAVA的流程
- eclipse写的swt程序的打包问题,在线等..........................
- oracle问题
- jbuilder多次運行后,爲什麽會出現tomcat 4.0 http 8080,tomcat 4.0 http 8083...?
- 异常能不能写在事件里面呢?
- 从小到大排列出10个数字
- 如何设置那个文件名过滤器的?
此处this 是一个 non-static variable
import java.awt.event.*;
import javax.swing.*;
public class TestFrame extends JFrame implements ActionListener
{
TestFrame()
{
this.setTitle("iori");
Button but = new Button("退出");
this.setSize(300,300);
add(but);
but.addActionListener(this);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.show();
}
public static void main(String[] args)
{
TestFrame f=new TestFrame();
}
public void actionPerformed(ActionEvent e) {this.dispose();
System.exit(0);
}
}
这是在main()方法中引起的问题吗?
这个是程序执行时间的问题
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class TestFrame extends Frame implements ActionListener {
public static void main(String[] args)
{
new TestFrame();
}
public TestFrame(){
Button but=new Button("退出");
Frame f=new Frame("www.it315.org");
f.add(but);
but.addActionListener(this);
f.setSize(300,300);
f.setVisible(true);
}public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}