JFileChooser.setSelectedFile("test.txt");
解决方案 »
- swith(ch)中的ch 为什么要定义成 int 类型?
- 新手求助
- 多版本jdk的安装与卸载
- 求助:如何在动态生成的树添加右键菜单,给提示者都有分,先谢谢了
- 如何捕获 Ctrl+Enter 事件
- 怎么样在让一个japplet 具有windows 风格显示啊
- jcreator 编译问题
- Map<String,Object> map = new HashMap<String,Object>();
- ie5.0支不支持java 2 appletviewer怎么用呀
- 请问如何下载一个页面下的所有子页面
- 哪位高手讲讲jre,j2se,jdk,j2ee,j2me,java VM等等术语的区别?
- 怎样最方便地把resultset中的第一个字段取出放在String[]中?
JFileChooser.setSelectedFile(new File("test.txt"));
文本框中还是什么都没有啊
下面是一段代码
saveButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String msg;
int result = fDialog.showSaveDialog(frame);
if(result == JFileChooser.APPROVE_OPTION){
//显示的文本方法如下:
fDialog.setSelectedFile(new File("test.txt"));
String fname = fDialog.getName(fDialog.getSelectedFile());
File file = new File(fname);
//fDialog.setSelectedFile(file);
path = fDialog.getCurrentDirectory();
//fDialog.setApproveButtonToolTipText("yes");
fDialog.setDialogTitle("yes");
String title = fDialog.getApproveButtonText();
//String title = fDialog.getDialogTitle();
//fDialog.setControlButtonsAreShown(false);
//System.out.println(title);
//file = new File(fname);
try{
//file =new File(path+fname);
String absolutePath = path.getAbsolutePath();
int length = absolutePath.length();
int c = length - 1;
//String test = absolutePath.subString(1,3);
if(absolutePath.substring(length - 1 ).equals("\\"))
System.out.println(absolutePath + fname);
else
System.out.println(absolutePath + "\\" + fname);
FileOutputStream fout = new FileOutputStream(path+fname);
BufferedOutputStream bout= new BufferedOutputStream(fout);
DataOutputStream dout = new DataOutputStream(bout);
//dout.writeInt(dataSize);
//for(int i = 0; i<dataSize; i++){
dout.writeChars("gen.nextDouble()");
//}
dout.flush();
fout.close();
System.out.println(dout.size() + "bytes written");
}
catch (IOException ee)
{
}