jframe和frame的区别
2个回答
2017-10-30
展开全部
import javax.swing.JFrame;
public class T2 extends JFrame{
private static final long serialVersionUID = 1L;
@SuppressWarnings("static-access")
public void init(){
//传递参数使得关闭按钮有效
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setTitle("JFrame");
this.setSize(320,240);
this.setVisible(true);
}
public static void main(String[] args){
T2 jframe = new T2();
jframe.init();
}
}
frame加监听使得关闭按钮有效
[html] view plain copy
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class T2 extends Frame{
private static final long serialVersionUID = -5650765517644858632L;
public void init(){
this.setSize(320,240);
this.setTitle("Frame");
//加监听使得关闭按钮有效
this.addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
this.setVisible(true);
}
public static void main(String[] args){
T2 frame = new T2();
frame.init();
}
}
public class T2 extends JFrame{
private static final long serialVersionUID = 1L;
@SuppressWarnings("static-access")
public void init(){
//传递参数使得关闭按钮有效
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setTitle("JFrame");
this.setSize(320,240);
this.setVisible(true);
}
public static void main(String[] args){
T2 jframe = new T2();
jframe.init();
}
}
frame加监听使得关闭按钮有效
[html] view plain copy
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class T2 extends Frame{
private static final long serialVersionUID = -5650765517644858632L;
public void init(){
this.setSize(320,240);
this.setTitle("Frame");
//加监听使得关闭按钮有效
this.addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
this.setVisible(true);
}
public static void main(String[] args){
T2 frame = new T2();
frame.init();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询