简易写字板软件设计实验报告Word下载.docx
- 文档编号:8661196
- 上传时间:2023-05-12
- 格式:DOCX
- 页数:26
- 大小:489.22KB
简易写字板软件设计实验报告Word下载.docx
《简易写字板软件设计实验报告Word下载.docx》由会员分享,可在线阅读,更多相关《简易写字板软件设计实验报告Word下载.docx(26页珍藏版)》请在冰点文库上搜索。
格式菜单实现了2个功能,分别是字体和颜色2个功能。
帮助菜单里只有关于写字板着一个功能。
各个菜单的功能见图2
图2各个菜单功能
2编辑区设计
编辑区实现的文本录入、自动换行和右击菜单功能。
如图3所示
图3右击功能
2.文件菜单中各项功能的实现
文件菜单包括新建、打开、保存、另存为和退出5部分
1建功能设计
当编辑区中不为空时,新健时会提醒是否保存,当点击是时怎出现另存为的对框如图4、5所示
图4
图5
当点击否时怎文本区清空。
2开功能设计
打开实现了在打开本地文件的功能,选择本地文件并打开在当前窗口。
如图6所示。
图6打开
3存功能设计
保存实现了在当前路径下保存当前文档,若无路径则添加路径。
若有的话直接保存如图7所示。
图7保存
4存为功能设计
另存为实现了在新路径下保存当前文档的功能。
如图8所示。
图8另存为
5出功能设计
退出实现了用户退出是提醒用户是否确定要退出。
如图9所示
图9退出
2.编辑菜单中各项功能的实现
编辑菜单包括剪切、复制、粘贴3部分,如图10所示。
图10
1剪切功能设计
剪切实现了对所选文本的剪切。
2复制功能设计
复制实现了对所选文本的复制。
3粘贴功能设计
粘贴实现了对当前文档剪贴板的粘贴。
3.格式菜单中各项功能的实现
格式菜单包括设置字体、字体颜色2部分,如图11所示。
图11颜色
图12颜色
4帮助菜单中各项功能的实现
帮助菜单包括查看“关于记事本”如图13所示
图13关于记事本
3收获与体会
听懂的不一定会做的出来只有实际中实实在在的做出来的才是自己的,经过这十几的不懈努力终于把自己的写字板给做了出来了,虽然比起真正的写字板要查很多,还有许多功能需要完善,但是这毕竟是在自己的努力下做出来的成功,还是高兴的。
在实际的操作中才逐渐的发现自己的不足,和实际当中的眼高手低的问题,总感觉自己都听懂了可实际操作下才明白这是有多么的差劲。
在用java的整个界面设计中不仅体现了自己编程能力更是要求自己对整个布局的把握通过不断的参考资料弥补了自己的不足同时也学到了很多课外的知识,是自己在对java综合知识的利用中更加熟练。
从中体会到了java编程的乐趣。
但是在java编程中这只是一个开头还有更多的知识需要我去把握,去学习。
从而在java方面走的更高。
在这里感谢李老师这学期的教导,谢谢老师
附录
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
importjava.io.*;
publicclassnote{
publicstaticvoidmain(Stringargs[]){
newnoted();
}
}
classnotedextendsJFrameimplementsActionListener{
JMenuBarmenu1;
JMenufile1,edit,form,help;
JMenuItemnewfile,open,save,assave,exit,copy,cut,paste,find,
replace,font1,color1,something,copy1,cut1,paste1,aboutnote;
JTextAreaarea;
JScrollPanepane;
JPopupMenumenu2;
//弹出式菜单
JFileChooserfilechooser;
publicnoted(){
setTitle("
无标题-写字板"
);
setBounds(200,200,600,400);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
area=newJTextArea(10,15);
area.setLineWrap(true);
area.setFont(newFont("
宋体"
Font.PLAIN,14));
pane=newJScrollPane(area);
add(pane,BorderLayout.CENTER);
menu1=newJMenuBar();
menu2=newJPopupMenu();
file1=newJMenu("
文件"
edit=newJMenu("
编辑"
form=newJMenu("
格式"
help=newJMenu("
帮助"
filechooser=newJFileChooser("
"
//文件及其相关项的设置于添加
newfile=newJMenuItem("
新建"
newfile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,InputEvent.CTRL_MASK));
open=newJMenuItem("
打开"
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,InputEvent.CTRL_MASK));
save=newJMenuItem("
保存"
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));
assave=newJMenuItem("
另存为"
assave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,InputEvent.CTRL_MASK));
exit=newJMenuItem("
退出"
exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_MASK));
file1.add(newfile);
file1.add(open);
file1.add(save);
file1.add(assave);
file1.addSeparator();
file1.add(exit);
menu1.add(file1);
//编辑及其子项的添加
copy=newJMenuItem("
复制"
copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_MASK));
cut=newJMenuItem("
剪切"
cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_MASK));
paste=newJMenuItem("
粘贴"
paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,InputEvent.CTRL_MASK));
//find=newJMenuItem("
查找"
//find.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,InputEvent.CTRL_MASK));
//replace=newJMenuItem("
替换"
//replace.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H,InputEvent.CTRL_MASK));
edit.add(copy);
edit.add(cut);
edit.add(paste);
//edit.addSeparator();
//edit.add(find);
//edit.add(replace);
menu1.add(edit);
//格式及其子项的添加
font1=newJMenuItem("
字体"
color1=newJMenuItem("
颜色"
form.add(font1);
form.add(color1);
menu1.add(form);
//帮助及其子项的添加
aboutnote=newJMenuItem("
关于写字板"
help.add(aboutnote);
menu1.add(help);
setJMenuBar(menu1);
//菜单条的设置
//鼠标右击的添加
copy1=newJMenuItem("
copy1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,InputEvent.CTRL_MASK));
cut1=newJMenuItem("
cut1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,InputEvent.CTRL_MASK));
paste1=newJMenuItem("
paste1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,InputEvent.CTRL_MASK));
menu2.add(copy1);
menu2.add(cut1);
menu2.add(paste1);
copy.addActionListener(this);
copy1.addActionListener(this);
cut.addActionListener(this);
cut1.addActionListener(this);
paste.addActionListener(this);
paste1.addActionListener(this);
color1.addActionListener(this);
newfile.addActionListener(this);
open.addActionListener(this);
assave.addActionListener(this);
save.addActionListener(this);
exit.addActionListener(this);
font1.addActionListener(this);
aboutnote.addActionListener(this);
//find.addActionListener(this);
validate();
area.addMouseListener(newMouseAdapter(){
publicvoidmousePressed(MouseEvente){
if(e.getModifiers()==InputEvent.BUTTON3_MASK){
menu2.show(area,e.getX(),e.getY());
}
}
});
//新建
publicvoidnewfile(){
if(!
area.getText().equals("
)){
intt=JOptionPane.showConfirmDialog(this,"
是否保存?
"
提示保存"
JOptionPane.YES_NO_CANCEL_OPTION);
if(t==JOptionPane.YES_OPTION){
save();
setTitle("
area.setText("
if(t==JOptionPane.NO_OPTION){
//打开
publicvoidopen(){
area.setText(null);
intn=filechooser.showOpenDialog(null);
if(n==JFileChooser.APPROVE_OPTION){
Filefile1=filechooser.getSelectedFile();
setTitle(file1.getName());
try{
FileReaderreaderfile=newFileReader(file1);
BufferedReaderin=newBufferedReader(readerfile);
Strings=null;
while((s=in.readLine())!
=null){
area.append(s+"
\n"
}
}
catch(IOExceptionee){}
//保存
publicvoidsave(){
intn=filechooser.showDialog(null,"
if(n==JFileChooser.APPROVE_OPTION){
Filefile2=filechooser.getSelectedFile();
if(!
file2.exists()){
setTitle(file2.getName());
try{
FileWriterwriterfile=newFileWriter(file2);
BufferedWriterout=newBufferedWriter(writerfile);
out.write(area.getText());
out.close();
writerfile.close();
catch(IOExceptioneee){}
else{
intm=JOptionPane.showConfirmDialog(this,file2.getName()+"
+"
已存在,是否要覆盖?
确认另存为"
JOptionPane.YES_NO_OPTION);
if(m==JOptionPane.YES_OPTION){
setTitle(file2.getName());
FileWriterwriterfile=newFileWriter(file2);
BufferedWriterout=newBufferedWriter(writerfile);
out.write(area.getText());
out.flush();
out.close();
writerfile.close();
catch(IOExceptioneee){}
}
}
publicvoidactionPerformed(ActionEvente){
Stringcontent=area.getText();
//得到文本域中的内容
if(e.getSource()==newfile){
newfile();
if(e.getSource()==open){
open();
if(e.getSource()==save){
if(getTitle().equals("
save();
if(file1.exists()){
FileWriterwriterfile=newFileWriter(file1);
BufferedWriterout=newBufferedWriter(writerfile);
out.write(area.getText());
out.flush();
out.close();
writerfile.close();
catch(IOExceptioneee){}
if(e.getSource()==assave){
save();
if(e.getSource()==exit){
退出之前是否保存"
退出提示"
JOptionPane.YES_NO_OPTION);
System.exit(0);
else{
System.exit(0);
if(e.getSource()==copy||e.getSource()==copy1){
area.copy();
if(e.getSource()==cut||e.getSource()==cut1){
area.cut();
if(e.getSource()==paste||e.getSource()==paste1){
area.paste();
/*if(e.getSource()==find){
findDialogfindD=newfindDialog(this);
}*/
if(e.getSource()==color1){
ColornewColor=JColorChooser.showDialog(this,"
字体颜色"
area.getForeground());
area.setForeground(newColor);
if(e.getSource()==font1){
fontframefontfr=newfontframe(this);
if(e.getSource()==aboutnote){
JOptionPane.showMessageDialog(this,
"
写字板1.0\n"
+
本软件用UltraEdit开发制作!
如有任何疑问及改善意见,随时欢迎指出,\n"
本人将尽最大的努力满足您的需求!
谢谢您的使用!
\n版权所有,请勿侵权!
如有雷同,纯属抄袭!
JOptionPane.INFORMATION_MESSAGE);
/*classfindDialogextendsJDialogimplementsActionListener{
JLabelfindLabel=newJLabel("
查找内容"
JLabelfang=newJLabel("
方向"
JTextFieldfindtext=newJTextField(10);
JButtonfindButton=newJButton("
查找下一个"
JButtoncanCle=newJButton("
取消"
JRadioButtonup=newJRadioButton("
向上"
JRadioButtondown=newJRadioButton("
向下"
true);
ButtonGroupbuGroup=newButtonGroup();
notednote1;
findDialog(notednote1){
this.note1=note1;
setBounds(300,400,440,100);
setLayout(null);
findLabel.se
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 简易 写字板 软件设计 实验 报告