作者在 2010-05-20 16:43:33 发布以下内容
package com.yds.gui.fourpart;
import java.awt.Button;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class FileSave implements ActionListener{
Button b1,b2;
FileDialog f_open,f_save;
Frame f;
public void Ui(){
f=new Frame("打开文件和保存文件");
b1=new Button("打开文件");
b1.addActionListener(this);
b2=new Button("保存文件");
b2.addActionListener(this);
f.add(b1,"North");
f.add(b2);
f.pack();
f.setVisible(true);
f_open=new FileDialog(f,"打开文件",FileDialog.LOAD);
f_save=new FileDialog(f,"打开文件",FileDialog.SAVE);
}
public static void main(String[] args) {
new FileSave().Ui();
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==b1){
f_open.setVisible(true);
}
else if(e.getSource()==b2){
f_save.setVisible(true);
}
}
}
import java.awt.Button;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class FileSave implements ActionListener{
Button b1,b2;
FileDialog f_open,f_save;
Frame f;
public void Ui(){
f=new Frame("打开文件和保存文件");
b1=new Button("打开文件");
b1.addActionListener(this);
b2=new Button("保存文件");
b2.addActionListener(this);
f.add(b1,"North");
f.add(b2);
f.pack();
f.setVisible(true);
f_open=new FileDialog(f,"打开文件",FileDialog.LOAD);
f_save=new FileDialog(f,"打开文件",FileDialog.SAVE);
}
public static void main(String[] args) {
new FileSave().Ui();
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==b1){
f_open.setVisible(true);
}
else if(e.getSource()==b2){
f_save.setVisible(true);
}
}
}