import javax.swing.*;
.
.
.
public class jCutter extends JFrame {
private JTextField textField;
private JButton button;
private JFileChooser fDialog;
private JFrame frame;
.
.
.
button = new JButton();
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
String msg;
fDialog=new JFileChooser(); //文件选择器
int result=fDialog.showOpenDialog(frame);
if(result==JFileChooser.APPROVE_OPTION){
String fname=fDialog.getName(fDialog.getSelectedFile());
frame.setTitle(fname);
msg="File Open Approved";
}else
msg="File Open Cancelled";
JOptionPane.showMessageDialog(frame,msg); //提示框
}
});