JDialog内部新定义的属性

来源:百度知道 编辑:UC知道 时间:2024/05/10 12:22:55
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class Notepad extends JFrame
{
public static void main(String[] args)
{
Notepad n = new Notepad();

}

public Notepad()
{
JButton j = new JButton("Close");
j.addActionListener(new MyActionListener());
add(j);
addWindowListener(new MyWindowListener());
setLocation(200, 200);
setSize(500, 300);
setVisible(true);
}

public class MyActionListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JDialogWhetherToSave jd = new JDialogWhetherToSave();
if (jd.close == true)//点三个按钮中任意一个都不会关闭窗体
{
System.exit(0);
}
}
}

public class MyWindowListener extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
JDialogWhetherToSave jd = ne

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.*; //Date needed
import java.io.PrintWriter;
public class NotePad extends JFrame
{
JTextArea jta;
class newl implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
jta.setText("");
}
}

class openl implements ActionListener
{ public void actionPerformed(ActionEvent e)
{
JFileChooser jf=new JFileChooser();
jf.showOpenDialog(NotePad.this);

}

}
//保存文件的监听
class savel implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
JFileChooser jf = new JFileChooser();
jf.showSaveDialog(NotePad.this);

}
}
//打印的监听 ?
class printl implements ActionListener
{
public void actionPerformed(ActionEvent e