ImageVerifierCode 换一换
格式:DOCX , 页数:39 ,大小:844.22KB ,
资源ID:5660956      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-5660956.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java课程设计Word格式文档下载.docx)为本站会员(b****2)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

java课程设计Word格式文档下载.docx

1、班 级:09-1学 号:540912010120指导教师:黄永丽、宋保卫、金松河 2011年7月2日一、引言11项目的名称 记事本程序12项目背景和目标 背景:掌握图形用户界面设计方法,掌握常用swing组件的使用和事件处理程序设计;掌握文件的I/O操作或程序对数据库的访问。 目标:利用eclipse开发环境,使用图形用户界面实现,能实现编辑、保存、另存为、查找替换等功能。二、需求分析21系统概述使用图形用户界面实现,能实现编辑、保存、另存为、查找替换等功能。22系统运行环境 Jdk-eclipse23功能需求描述 能实现编辑、保存、另存为、查找替换等功能。三、总体设计31开发与设计的总体思想

2、 a分析题目 b根据自己的想法搭建程序界面 c为各个菜单项添加事件处理程序32模块设计 a主界面模块图 1b.菜单栏界面模块图 2图3图4图5四、详细设计1主界面模块public class Editor extends JFrame implements ActionListener private JMenu file, edit, view, about; private JMenuBar jmb; private JTextArea jta; private JScrollPane jsp; private JPopupMenu pop; private boolean wasSave

3、d = true; private File currentFile = null; private Object text; public static void main(String args) new Editor().init(); public Editor() this.setName(文本编辑器1.0); pop = new JPopupMenu(); file = new JMenu(文件 edit = new JMenu(编辑 view = new JMenu(查看 about = new JMenu(关于 jmb = new JMenuBar(); jta = new J

4、TextArea(30, 30); jsp = new JScrollPane(jta); jta.addMouseListener(new MouseAdapter() Override public void mouseClicked(MouseEvent arg0) if (arg0.getButton() = MouseEvent.BUTTON1) pop.setVisible(false); public void mouseReleased(MouseEvent e) if (e.getButton() = MouseEvent.BUTTON3) pop.show(edit, e.

5、getX(), e.getY(); pop.setVisible(true); ); jta.getDocument().addDocumentListener(new DocumentListener() public void changedUpdate(DocumentEvent arg0) wasSaved = false; public void insertUpdate(DocumentEvent arg0) public void removeUpdate(DocumentEvent arg0) JMenuItem item; file.add(item = new JMenuI

6、tem(新建); item.addActionListener(this);打开. file.addSeparator();保存另存为.退出 edit.add(item = new JMenuItem(复制粘贴剪切 edit.addSeparator();替换.查找.全选 view.add(item = new JMenuItem(字体.颜色. about.add(item = new JMenuItem(关于.2.菜单栏界面模块A文件菜单模块保存界面截图图6图7保存界面代码if (command.equals() if (!wasSaved) if (currentFile = null)

7、JFileChooser jfc = new JFileChooser(); jfc.showSaveDialog(this); File f = jfc.getSelectedFile(); if (f != null) savetoFile(f); currentFile = f; else savetoFile(currentFile); return; public void savetoFile(File f) FileWriter fw = null; try fw = new FileWriter(f); fw.write(jta.getText(); fw.flush(); w

8、asSaved = true; catch (IOException e) e.printStackTrace(); finally if (fw != null) try fw.close(); catch (IOException e) 打开已保存文件界面截图图8图9打开已保存文件代码 if (askSave() = 0) return; if (askSave() = 1) jta.setText( JFileChooser jfc = new JFileChooser(); jfc.showSaveDialog(this); File f = jfc.getSelectedFile()

9、; if (f ! currentFile = f; openFile(f);public void openFile(File f) FileReader fr = null; BufferedReader br = null; fr = new FileReader(f); br = new BufferedReader(fr); String str = null; while (str = br.readLine() ! jta.append(str + n catch (Exception e) try Thread.sleep(200); catch (InterruptedExc

10、eption e1) wasSaved = false; if (br ! br.close(); catch (Exception e) if (fr ! fr.close();文件另存为界面截图图10图11 文件另存为代码 if (command.equals( savetoFile(f);退出界面截图图12图13退出界面代码 else System.exit(0);public int askSave() if (!wasSaved) / 如果没有保存 int choice = JOptionPane.showConfirmDialog(this, 是否保存文件?, 保存文件?, JOp

11、tionPane.YES_NO_CANCEL_OPTION); switch (choice) case JOptionPane.OK_OPTION: / 要求保存文件 if (currentFile = null) / 如果是新建文件 else / 如果是打开的旧文件 return 1; case JOptionPane.NO_OPTION:/ 不保存文件 case JOptionPane.CANCEL_OPTION: return 0;/ 取消 return -1;B.编辑菜单模块复制模块截图图14复制模块代码 jta.copy(); pop.setVisible(false);粘贴模块截

12、图图15图16粘贴模块代码 jta.paste();剪切界面截图图17图18剪切界面代码 jta.cut();全选界面截图图19图20全选界面代码 jta.selectAll();C.查看菜单模块颜色菜单模块截图图21图22图23图24颜色菜单模块代码 Color c = JColorChooser.showDialog(this, 请选择文字颜色, Color.BLACK); jta.setForeground(c);五、实现和源程序import java.awt.BorderLayout;import java.awt.Color;import java.awt.Font;import j

13、ava.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.io.FileWrit

14、er;import java.io.IOException;import javax.swing.AbstractButton;import javax.swing.JColorChooser;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JMenu;import javax.swing.JMenuBar;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.JPopupMenu;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;import javax.swing.text.JTextComponent; edit.add(item = n

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2