云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 实现记事本功能模板

实现记事本功能模板

  • 62 次阅读
  • 3 次下载
  • 2025/6/23 3:18:09

西安文理学院数学与计算机工程学院 课程设计报告

附录

主要程序代码:

import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*;

class mynotepad extends JFrame{

File file=null; Color color=Color.red; mynotepad(){ initTextContent(); initMenu(); initAboutDialog(); void initTextContent()

getContentPane().add(new JScrollPane(content));

JTextPane content=new JTextPane(); JColorChooser opencolor=new JColorChooser(); new JMenu new JMenu

JMenuItem optionofmenu[][]=new JMenuItem[][]{{

new JMenuItem; void initMenu(){

for(int i=0;i

for(int j=0;j

optionofmenu[i][j].addActionListener this.setJMenuBar(menu);

ActionListener action=new ActionListener(){

- 18 -

西安文理学院数学与计算机工程学院 课程设计报告

public void actionPerformed(ActionEvent e){

String name = e.getActionCommand(); JMenuItem MI=(JMenuItem)e.getSource(); if(file !=null)openfile.setSelectedFile(file);

int returnVal=openfile.showOpenDialog(mynotepad.this); if(returnVal==JFileChooser.APPROVE_OPTION){ file=openfile.getSelectedFile(); unfold(); else if .equals(name)){

if(file!=null) openfile.setSelectedFile(file);

int returnVal=openfile.showSaveDialog(mynotepad.this);

if(returnVal==JFileChooser.APPROVE_OPTION){ file=openfile.getSelectedFile(); else if .equals(name)){

mynotepad f=new mynotepad();

int s=JOptionPane.showConfirmDialog(

if(s==JOptionPane.YES_OPTION) System.exit(0);

color=JColorChooser.showDialog(mynotepad.this,\content.setForeground(color); void saving

try{

FileWriterWritef=newFileWriter(file); Writef.write(content.getText()); Writef.close();

catch(Exception e){e.printStackTrace();} void unfold(){

try{

FileReaderReadf=newFileReader(file);

- 19 -

西安文理学院数学与计算机工程学院 课程设计报告

int len=(int)file.length(); char []buffer=new char[len]; Readf.read(buffer,0,len); Readf.close();

content.setText(new String(buffer));

}catch(Exception e){e.printStackTrace();} void initAboutDialog(){

about.setLayout(new GridLayout(3,1));

about.getContentPane().setBackground(Color.white) about.setModal(true); about.setSize(100,100);

about.setLocation(250,170); public class Notepad{

public static void main(String args[]){ mynotepad noted=new mynotepad(); noted.addWindowListener(new WindowAdapter(){

noted.setSize(640,320); noted.show();

noted.setLocation(150,100);

参考文献:

C程序设计(第三版)

谭浩强,张基文编著.C语言程序设计教程 Herbert Schildt.C语言大全(第二版) C++面向对象程序设计

Harveym.Deitel C++大学教程(第二版) 吴文虎.程序设计大全[M] JAVA面向对象程序设计

Bruce Eckel.java编程思想.第四版

Cay S Horstmann,Gary Cornell.java核心技术卷一.第八版 Joshua Bloch.Effective Java中文版

相关资料网址:http://www.tup.tsinghua.edu.cn

http://www. ptpress.com.cn

- 20 -

搜索更多关于: 实现记事本功能模板 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

西安文理学院数学与计算机工程学院 课程设计报告 附录 主要程序代码: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; class mynotepad extends JFrame{ File file=null; Color color=Color.red; mynotepad(){ initTextContent(); initMenu(); initAboutDialog(); void initTextContent() getContentPane().add(new JScrollPane(content)); JTextPane

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com