2023年12月2日发(作者:)
设置打开或保存文件对话框的文件类型
import yout;
import Event;
import Listener;
import edWriter;
import ;
import iter;
import ption;
import ;
import n;
import Box;
import hooser;
import ;
import ;
import dFeel;
import ger;
import ortedLookAndFeelException;
import meExtensionFilter;
/**
* 1.设置打开或保存文件时弹出的对话框的文件类型选择。
* 2.外观选择。
* @author EX-QINCIDONG001
*
*/
public class FileSaveExtensionChooser extends JFrame{
}
public String toString() {
}
return name;
SupportedLaF(String name, LookAndFeel laf) {
}
= name;
= laf;
private JButton btn = new JButton("保存文件");
private JComboBox laf;
private Vector
static class SupportedLaF {
String name;
LookAndFeel laf;
public FileSaveExtensionChooser() {
setSize(300,200);
setVisible(true);
setLocationRelativeTo(null);
setLayout(new FlowLayout());
add(btn);
add(new JLabel("选择外观:"));
setLookAndFeel();
add(laf);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
ionListener(new ActionListener() {
});
public void actionPerformed(ActionEvent arg0) {
}
String msg = "Hello World!";
JFileChooser jfc = new JFileChooser();
FileNameExtensionFilter fnef = new FileNameExtensionFilter("TXT and
FileNameExtensionFilter txt = new FileNameExtensionFilter("TXT Files
FileNameExtensionFilter ini = new FileNameExtensionFilter("INI Files
osableFileFilter(fnef);
osableFileFilter(txt);
osableFileFilter(ini);
logType(_DIALOG);
int res = veDialog();
if (res == E_OPTION) {
}
File file = ectedFile();
n(olutePath());
try {
}
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
(msg);
();
();
n("File Save Finished!");
// TODO Auto-generated catch block
tackTrace();
INI Files (.txt, .ini)", "txt","ini");
(.txt)", "txt");
(.ini)", "ini");
} catch (IOException e) {
}
ionListener(new ActionListener() {
});
pack();
public void actionPerformed(ActionEvent arg0) {
}
SupportedLaF slaf = (SupportedLaF) ectedItem();
try {
}
kAndFeel();
n("Set LookAndFeel To " + );
// TODO Auto-generated catch block
tackTrace();
} catch (UnsupportedLookAndFeelException e) {
public void setLookAndFeel() {
}
/**
* @param args
*/
public static void main(String[] args) {
}
FileSaveExtensionChooser t2 = new FileSaveExtensionChooser();
dFeelInfo[] installedLafs = UIManager
}
laf = new JComboBox(supportedLookAndFeel);
ectedIndex(0);
.getInstalledLookAndFeels();
for (dFeelInfo lafInfo : installedLafs) {
try {
}
Class lnfClass = e(ssName());
LookAndFeel laf = (LookAndFeel) (tance());
if (ortedLookAndFeel()) {
}
continue;
String name = e();
(new SupportedLaF(name,laf));
} catch (Exception e) { }


发布评论