你最好还是找相关的API来看。很多东西用不到啊
解决方案 »
- 谁能帮小弟用JAVA写下冒泡法~多谢~
- 关于Document 是怎么工作的??
- 关于servlet能处理中文的问题?
- 请假各位大虾,怎么使用JMF开发一个网络视频会议系统
- 我妹妹要考JAVA, 有几道题不知道怎么做,请大家帮忙(在线等)
- 原来还可以,为什么加入xml操作后,再打包后的jar文件运行没反应了
- 请问哪儿有jbuilder的中文版教程下载?100分相送
- int型(or short)怎样转换为byte[]型啊?新手求救
- 一个菜鸟的关于Java
- Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
- java中有类似于Wget的类库马?
- 请教一关于抽象方法的问题
给个例子:
class EDBFileFilter
extends javax.swing.filechooser.FileFilter {
public boolean accept(File file) {
if (file.isDirectory() || file.getPath().toLowerCase().endsWith(".txt") || file.getPath().toLowerCase().endsWith(".java"))
return true;
else
return false;
} public String getDescription() {
return "(.txt, .java)";
}
} JFileChooser fc = new JFileChooser();
fc.addChoosableFileFilter(new EDBFileFilter());
最基础的
jFileChooser = new JFileChooser("c:\\");//默认的打开路径
int result = jFileChooser.showOpenDialog(jDialog);
jFileChooser.setDialogTitle("New File"); if (result == JFileChooser.APPROVE_OPTION) {
File file = jFileChooser.getSelectedFile();
textField.setText(file.getPath());//得到选择的路径
}
return;
import javax.swing.*;public class JFileTyper
{
public static void main(String[] args)
{
JFileChooser fc = new JFileChooser();
// fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fc.setMultiSelectionEnabled(true);
int result = fc.showOpenDialog(new JFrame());
if (result == JFileChooser.APPROVE_OPTION)
{
File[] f = fc.getSelectedFiles();
if (f != null)
{
for (int i = 0; i < f.length; i++)
{
System.out.println(f[i].getName());
}
}
}
}
}