看不太懂。注:save 是保存按钮,diaClose是保存对话框,ta是文本框(毕向东老师第22天的视频的内容)
[code=java]
save.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(file==null)
{
diaClose.setVisible(true);
String dirPath=diaClose.getDirectory();
String fileName=diaClose.getFile();
if(dirPath==null||fileName==null)
{
return;
}
File file=new File(dirPath,fileName);
}
try
{
BufferedWriter bw=new BufferedWriter(new FileWriter(file));
String text=ta.getText();
bw.write(text);
bw.close();
}
catch (IOException m)
{
throw new RuntimeException();
}
}
});[/code] |
|