噶米课程基于于JAVA的记事本编辑器的与实现(下载后送源代码)

内容发布更新时间 : 2024/6/15 17:13:20星期一 下面是文章的全部内容请认真阅读。

} filedialog_load.getFile()); file_reader=new FileReader(file); in=new BufferedReader(file_reader); while((s=in.readLine())!=null) area.append(s+'\\n'); in.close(); file_reader.close(); } catch(IOException e1) {} } else if(e.getSource()==item1) { area.setText(null); } else if(e.getSource()==item2) { area.cut(); } else if(e.getSource()==item3) { area.copy(); } else if(e.getSource()==item4) { area.paste(); } else if(e.getSource()==item5) { Color newColor=JColorChooser.showDialog(this,\调色板\if(newColor!=null) area.setBackground(newColor); } else if(e.getSource()==item6) { zhuti zt=new zhuti(); } else if(e.getSource()==item7) { System.exit(0); } else if(e.getSource()==item8) { Font font=area.getFont(); int style=font.getStyle(); style=style^0; area.setFont(new Font(\ } else if(e.getSource()==item9) { Font font=area.getFont(); int style=font.getStyle(); style=style^2; area.setFont(new Font(\ } else if(e.getSource()==item10) { Font font=area.getFont(); int style=font.getStyle(); style=style^1; area.setFont(new Font(\ } } else if(e.getSource()==item11) { Font font=area.getFont(); int style=font.getStyle(); area.setFont(new Font(font.getName(),style,12)); } else if(e.getSource()==item12) { Font font=area.getFont(); int style=font.getStyle(); area.setFont(new Font(font.getName(),style,24)); } else if(e.getSource()==item13) { Font font=area.getFont(); int style=font.getStyle(); area.setFont(new Font(font.getName(),style,36)); } else if(e.getSource()==item14) { chazhao cz=new chazhao(); } } class zhuti extends Frame implements ActionListener { Button btn; Label lab; zhuti() { setLayout(null); btn=new Button(\确定\ lab=new Label(\这是一个简单的文本编辑器!\ } add(btn); add(lab); btn.addActionListener(this); setBounds(200,200,250,150); setVisible(true); lab.setBounds(20 ,60,220,30); lab.setFont(new Font(\楷体\lab.setBackground(Color.cyan); btn.setBounds(100,100,50,30); btn.setBackground(Color.cyan); } public void actionPerformed(ActionEvent e) { if(e.getSource()==btn) { } dispose(); } public class MyWork { public static void main(String args[]) { Window win=new Window(\甜甜的文本编辑器\} } 5.课程设计心得 本次课程设计我选做的题目是文本编辑器的设计与实现. 要求设计一个类似于Windows记事本(Notepad)的Java程序,可以打开、新建、保存一个文本文件,而且能对选中的文本进行各种编辑操作,如设置字体、背景、复制、粘贴. 这次实验中我设计的文本编辑器可以实现打开, 新建,保存,复制,粘贴,剪贴,背景,及帮助主题这些功能.先在Window类中添加一系列组件,如Button,JtextArea,Menu等,再对相应的组件添加监听,然后在各自对应的方法中来实现各自的功能. 先设置了四个菜单,分别为文件,编辑,格式和帮助. 将打开, 新建,保存放入文件菜单中, 复制,粘贴,剪贴放入编辑菜单中,背景和关于主题分别在格式和帮助菜单中. 通过这次的课程设计,应该说收益匪浅,因为程序都是自己写的,所以感触更深。以前有一些似懂非懂的知识点通过这次试验有了全面的了解,更重要的是得到了许多新的知识。 而且在这次试验中尝试了许多以前没有用过的方法来实现一些功能,比如对话框的使用等等。有了这次课程设计的体验,相信在以后的编程乃至学习中会从中得到一些经验。 参考文献: [1] 耿祥义,张跃平著.Java2实用教程(第三版)[M].清华大学出版社,2006 [2] 陈家兴,陈风,朱国鸿著.Java图形用户界面设计与实例[M].冶金工业出版社,2004 [3]《Java2使用教程(第三版)》耿祥义 张跃平编著 北京:清华大学出版社,2007 [4] Internet上的资源

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4 ceshi