盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

JBuilder 9 开发一个文本编辑器

时间:2024/10/8作者:未知来源:盾怪网教程人气:

[摘要]save事件处理器中的代码收集到新的 saveFile()方法中,即可从菜单处理器也可从按钮处理器对其调用。   // Save current file; handle not yet havin...
save事件处理器中的代码收集到新的 saveFile()方法中,即可从菜单处理器也可从按钮处理器对其调用。

  // Save current file; handle not yet having a filename; report to statusBar.
  boolean saveFile() {
  // Handle the case where we don't have a file name yet.
  if (currFileName == null) {
  return saveAsFile();
  }
  try
  {
  // Open a file of the current name.
  File file = new File (currFileName);
  // Create an output writer that will write to that file.
  // FileWriter handles international characters encoding conversions.
  FileWriter out = new FileWriter(file);
  String text = jTextArea1.getText();
  out.write(text);
  out.close();
  this.dirty = false;
  // Display the name of the saved directory+file in the statusBar.
  statusBar.setText("Saved to " + currFileName);
  updateCaption();
  return true;
  }
  catch (IOException e) {
  statusBar.setText("Error saving " + currFileName);
  }
  return false;
  }

  建helpAbout()方法

  对Help

关键词:JBuilder 9 开发一个文本编辑器




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版