class MyFrame extends JFrame {
...
public MyFrame() {
...
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
...
}
...
public MyFrame() {
...
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
...
}
解决方案 »
- 关于double类型的数值运算,,,求大神解答
- 请问"void"是什么意思?
- 关于String中的一个方法的用法 请指点!
- 写了1个邮件发送程序,在本机测试就能发送出去,但是放到别的机器上就发布出去,求解,谢谢
- 关于学习JAVA的入门困惑,帮我解答下好吗?
- 新手求助,用EditPlus开发时,出错了,
- 关于forClass,getClass,forName方法的使用..
- 几个JAVA基础的小问题,看看你理解如何,另外请教,当String A ="abc"; String B="abc" A 和 B是指向同一块内存吗?
- 关于javah 的问题
- 如何
- 用过iplanet Directory Server的朋友请留下您的地址。
- 请问:System类的load,loadLibrary, mapLibraryName起什么作用?
import java.awt.event.*;
import java.util.regex.*;
import javax.swing.*;
import javax.swing.event.*;
public class TextTest{
public static void main(String args[]){
JFrame frame=new TextShow();
frame.show();
}
}
class TextShow extends JFrame{
int x=150/10;
int y=200/20;
private JTextArea tf=new JTextArea();
private JButton btnRead=new JButton("读取");
private JButton btnSave=new JButton("保存");
public TextShow(){
//ImageIcon img=new ImageIcon("real.gif");
//setIconImage(img.getImage());
setTitle("文件更新实例");
setSize(150,200);
setResizable(false);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
Container content=getContentPane();
content.setLayout(null);
content.add(tf);
content.add(btnRead);
content.add(btnSave);
tf.setBounds(x,y,8*x,12*y);
btnRead.setBounds(x,14*y,4*x,2*y);
btnSave.setBounds(4*x,14*y,4*x,2*y);
btnRead.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e){
}
public void mousePressed(MouseEvent e){
//此处加入文件读取代码并在tf中显示
}
public void mouseReleased(MouseEvent e){
}
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
});
btnSave.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e){}
public void mousePressed(MouseEvent e){
//此处加入文件保存代码
}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
});
}
}