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

JBuilder 9 开发一个文本编辑器

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

[摘要]Font 菜单项开始,该菜单将引出一个FontChooser (字型选择)对话框。   给FontChooser附加一个菜单项事件(源程序)如下:   void jMenuItem5_actionP...
Font 菜单项开始,该菜单将引出一个FontChooser (字型选择)对话框。
  给FontChooser附加一个菜单项事件(源程序)如下:


  void jMenuItem5_actionPerformed(ActionEvent e) {
  // Handle the "Edit Font" menu item
  // Pick up the existing font from the text area
  // and put it into the FontChooser before showing
  // the FontChooser, so that we are editing the
  // existing / previous font.

  fontChooser1.setSelectedFont(jTextArea1.getFont());

  // Obtain the new Font from the FontChooser.
  // First test the return value of showDialog() to
  // see if the user pressed OK.
  if (fontChooser1.showDialog()) {
  // Set the font of jTextArea1 to the font
  // the user selected before pressing the OK button
  jTextArea1.setFont(fontChooser1.getSelectedFont());
  }
  //repaints menu after item is selected
  this.repaint();
  //Repaints text properly if some text is highlighted when font is changed.
  jTextArea1.repaint();
  }

  给JcolorChooser(颜色选择)附加一个菜单项事件

  创建Edit

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




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

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

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