




已阅读5页,还剩30页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
重庆交通大学信息科学与工程学院综合性设计性实验报告班 级: 07通信(二)班 姓名 (学号): 实验项目名称: 浏览器 实验室(中心): 信息科学与工程学院软件中心 指 导 教 师 : 王勇 实验完成时间: 2010 年 6 月 30 日目 录一、设计题目.1二、题目分析.1三、实验条件.2四、功能模块图 .2五、开发过程.4六、完整源代码.8七、运行界面.33八、实验相关问题 .36九、设计体会 .39十、参考文献 .40一、设计题目浏览器二、题目分析1.浏览器的功能:该浏览器由一个Java的Application程序来实现,包括:(1)浏览网页,包括网页内部的超链接响应事件,鼠标的响应事件;(2)后退,前进,刷新,主页,转到等按钮的设计;(3)记录历史记录并显示最近浏览的10个网页的历史记录;(4)书签的相应操作,包括:添加书签,删除书签,上移和下移书签;(5)弹出菜单的相关设计;(6)网页源代码的显示;(7)其余的相关设计2.浏览器的基本组件:(1)菜单条:包含文件、标签、查看和帮助四个菜单项;文件菜单项:包含 “退出”子菜单项;标签菜单项:包含 “加入书签”、“删除书签”、“上移书签”、“下移书签”子菜单项;查看菜单项:包含“源代码”、“历史记录”、“删除记录”、“编码”、“设置背影颜色”子菜单项,其中编码菜单项又包含由各种编码构成的子菜单项;帮助菜单项包含 “关于浏览器”和“每日一句”子菜单项。(2)工具条:包括后退、前进、刷新、主要、转到、五个图标,显示为“Location:”的标签,用于输入和显示URL的文本输入框。(3)主窗口:显示网页的区域,带有垂直滚动条和水平滚动条。(4)提示对话框:显示错误信息和帮助等提示信息。(5)窗浏窗口下栏:包含显示浏览的网页的URL信息的标签和进度栏。三、实验条件1,硬件:PC机一台2,软件:NetBeans IDE 6.8四、功能模块图Browser导航354.1菜单栏的模块设计:4.2工具栏的模块设计:4.3浏览窗口的模块设计:五、开发过程5.1 构建浏览器的设计面板首先构建浏览器界面,添加菜单栏jMenuBar1jMenuBar,工具栏jToolBar1jToolBar,浏览窗口WindowsJEditorPane,以及相关控件。5.2 菜单栏的相关设计:5.2.1 文件的设计: 退出File_exitJmenuItem使用System.exit(0)实现浏览器的退出功能; 5.2.2 添加书签和删除书签的设计思想 注:书签上移和书签下移的设计思想与删除书签的设计思想相同 添加添加书签子菜单项的事件响应函数:private void BookMark_addActionPerformed(ActionEvent evt);删除书签的事件响应函数private void BookMark_DelActionPerformed(ActionEvent evt); 5.2.2 源代码的设计思想 5.2.3 历史记录的设计思想 注:删除记录的设计思想与删除书签的设计思想相同5.3 菜单栏的相关设计: 5.3.1 后退按钮与前进按钮的设计思想5.3.2 刷新按钮和转动按钮的设计思想5.3.3 URLJTextFiled的设计 添加URL的KeyPressed事件,设定响应函数与转动按钮的事件响应相同,使得达到同样的效果。 5.4 浏览窗口的相关设计: 设计浏览器的窗口WindowsJeditorPane,(1)首先通过定制代码Windows.setEditor(false);将网页置位不可编辑状态,添加WindowsHyperlink事件,并进行网页超链接事件响应相关设计;(2)添加mousePressed事件,进行事件响应相关设计弹出菜单: 在设计面板中添加弹出菜单JPopupMenu,并在弹出菜单中添加子菜单JMenuItem,并添加各个子菜单项的事件响应函数,其中,弹出菜单中的各个子菜单项均在菜单栏或工具栏中出现,故弹出菜单的各个子菜单项的事件响应函数中只是进行了调用已存在的按钮或者菜单项的事件响应函数。六、完整源代码/* * Browser.java * * Created on 2010-6-17, 23:30:17 */package browser;import java.awt.Color;import java.awt.Cursor;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.KeyEvent;import java.io.BufferedInputStream;import java.io.BufferedWriter;import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.io.InputStream;import .MalformedURLException;import .URL;import .URLDecoder;import java.util.ArrayList;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JColorChooser;import javax.swing.JMenuItem;import javax.swing.JOptionPane;import javax.swing.event.HyperlinkEvent;/* author 王敏07950213 */public class Browser extends javax.swing.JFrame implements ActionListener public Browser() initComponents(); setTitle(07级通信工程二班王敏079502132010年06月); SuppressWarnings(unchecked) / private void initComponents() PopupMenu1 = new javax.swing.JPopupMenu(); HTML2 = new javax.swing.JMenuItem(); BookeMarkAdd = new javax.swing.JMenuItem(); jSeparator9 = new javax.swing.JPopupMenu.Separator(); Reload = new javax.swing.JMenuItem(); HomePage2 = new javax.swing.JMenuItem(); jSeparator10 = new javax.swing.JPopupMenu.Separator(); Exit = new javax.swing.JMenuItem(); jToolBar1 = new javax.swing.JToolBar(); Back = new javax.swing.JButton(); Forward = new javax.swing.JButton(); Refresh = new javax.swing.JButton(); HomePage = new javax.swing.JButton(); Location = new javax.swing.JLabel(); URL = new javax.swing.JTextField(); Go = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); Windows = new javax.swing.JEditorPane(); jProgressBar1 = new javax.swing.JProgressBar(); Label = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); File = new javax.swing.JMenu(); File_exit = new javax.swing.JMenuItem(); Seek = new javax.swing.JMenu(); HTML = new javax.swing.JMenuItem(); Separator = new javax.swing.JPopupMenu.Separator(); History = new javax.swing.JMenu(); History_Show = new javax.swing.JMenuItem(); jSeparator2 = new javax.swing.JPopupMenu.Separator(); History_Del = new javax.swing.JMenuItem(); jSeparator3 = new javax.swing.JPopupMenu.Separator(); Code = new javax.swing.JMenu(); UTF8 = new javax.swing.JMenuItem(); jSeparator4 = new javax.swing.JPopupMenu.Separator(); GB2312 = new javax.swing.JMenuItem(); GB18030 = new javax.swing.JMenuItem(); jSeparator5 = new javax.swing.JPopupMenu.Separator(); Others = new javax.swing.JMenu(); UTF16 = new javax.swing.JMenuItem(); UCS4 = new javax.swing.JMenuItem(); jSeparator6 = new javax.swing.JPopupMenu.Separator(); GBK = new javax.swing.JMenuItem(); Big5 = new javax.swing.JMenuItem(); jSeparator7 = new javax.swing.JPopupMenu.Separator(); KOI8R = new javax.swing.JMenuItem(); KOI8U = new javax.swing.JMenuItem(); GroundColor = new javax.swing.JMenuItem(); BookMark = new javax.swing.JMenu(); BookMark_add = new javax.swing.JMenuItem(); BookMark_del = new javax.swing.JMenuItem(); jSeparator8 = new javax.swing.JPopupMenu.Separator(); BookMarkUp = new javax.swing.JMenuItem(); BookMarkDown = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JPopupMenu.Separator(); Help = new javax.swing.JMenu(); About = new javax.swing.JMenuItem(); Daily_Sentence = new javax.swing.JMenuItem(); HTML2.setText(源文件); HTML2.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) HTML2ActionPerformed(evt); ); PopupMenu1.add(HTML2); BookeMarkAdd.setText(添加书签); BookeMarkAdd.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) BookeMarkAddActionPerformed(evt); ); PopupMenu1.add(BookeMarkAdd); PopupMenu1.add(jSeparator9); Reload.setText(刷新); Reload.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) ReloadActionPerformed(evt); ); PopupMenu1.add(Reload); HomePage2.setText(主页); HomePage2.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) HomePage2ActionPerformed(evt); ); PopupMenu1.add(HomePage2); PopupMenu1.add(jSeparator10); Exit.setText(退出); Exit.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) ExitActionPerformed(evt); ); PopupMenu1.add(Exit); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jToolBar1.setRollover(true); Back.setIcon(new javax.swing.ImageIcon(getClass().getResource(/images/Back.png); / NOI18N Back.setFocusable(false); Back.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); Back.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); Back.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) BackActionPerformed(evt); ); jToolBar1.add(Back); Forward.setIcon(new javax.swing.ImageIcon(getClass().getResource(/images/Forward.png); / NOI18N Forward.setFocusable(false); Forward.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); Forward.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); Forward.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) ForwardActionPerformed(evt); ); jToolBar1.add(Forward); Refresh.setIcon(new javax.swing.ImageIcon(getClass().getResource(/images/Reload.png); / NOI18N Refresh.setFocusable(false); Refresh.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); Refresh.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); Refresh.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) RefreshActionPerformed(evt); ); jToolBar1.add(Refresh); HomePage.setIcon(new javax.swing.ImageIcon(getClass().getResource(/images/item_property.jpg); / NOI18N HomePage.setFocusable(false); HomePage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); HomePage.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); HomePage.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) HomePageActionPerformed(evt); ); jToolBar1.add(HomePage); Location.setText(Location:); jToolBar1.add(Location); URL.setText(); URL.addKeyListener(new java.awt.event.KeyAdapter() public void keyPressed(java.awt.event.KeyEvent evt) URLKeyPressed(evt); ); jToolBar1.add(URL); Go.setIcon(new javax.swing.ImageIcon(getClass().getResource(/images/item_allstart.jpg); / NOI18N Go.setFocusable(false); Go.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); Go.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); Go.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) GoActionPerformed(evt); ); jToolBar1.add(Go); Windows.addMouseListener(new java.awt.event.MouseAdapter() public void mousePressed(java.awt.event.MouseEvent evt) WindowsMousePressed(evt); ); Windows.addHyperlinkListener(new javax.swing.event.HyperlinkListener() public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent evt) WindowsHyperlinkUpdate(evt); ); jScrollPane1.setViewportView(Windows); Windows.setContentType(text/html); Windows.setEditable(false); File.setText(文件); File_exit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0); File_exit.setText(退出); File_exit.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) File_exitActionPerformed(evt); ); File.add(File_exit); jMenuBar1.add(File); Seek.setText(查看); HTML.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0); HTML.setText(源文件); HTML.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) HTMLActionPerformed(evt); ); Seek.add(HTML); Seek.add(Separator); History.setText(历史记录); History_Show.setText(历史记录显示10); History.add(History_Show); History.add(jSeparator2); Seek.add(History); History_Del.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK); History_Del.setText(删除记录); History_Del.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) History_DelActionPerformed(evt); ); Seek.add(History_Del); Seek.add(jSeparator3); Code.setText(编码); UTF8.setText(自动选择(UTF-8); Code.add(UTF8); Code.add(jSeparator4); GB2312.setText(简体中文GB2312); Code.add(GB2312); GB18030.setText(简体中文GB18030); Code.add(GB18030); Code.add(jSeparator5); Others.setText(其他); UTF16.setText(unicode(UTF-16); Others.add(UTF16); UCS4.setText(UCS-4); Others.add(UCS4); Others.add(jSeparator6); GBK.setText(简体中文GBK); Others.add(GBK); Big5.setText(简体中文Big5); Others.add(Big5); Others.add(jSeparator7); KOI8R.setText(西里尔文KOI8-R); Others.add(KOI8R); KOI8U.setText(西里尔文KOI8-U); Others.add(KOI8U); Code.add(Others); Seek.add(Code); GroundColor.setText(设置背景颜色); GroundColor.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) GroundColorActionPerformed(evt); ); Seek.add(GroundColor); jMenuBar1.add(Seek); BookMark.setText(标签); BookMark_add.setText(添加书签); BookMark_add.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) BookMark_addActionPerformed(evt); ); BookMark.add(BookMark_add); BookMark_del.setText(删除书签); BookMark_del.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) BookMark_delActionPerformed(evt); ); BookMark.add(BookMark_del); BookMark.add(jSeparator8); BookMarkUp.setText(上移书签); BookMarkUp.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) BookMarkUpActionPerformed(evt); ); BookMark.add(BookMarkUp); BookMarkDown.setText(下移书签); BookMarkDown.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) BookMarkDownActionPerformed(evt); ); BookMark.add(BookMarkDown); BookMark.add(jSeparator1); jMenuBar1.add(BookMark); Help.setText(帮助); About.setText(关于浏览器); About.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) AboutActionPerformed(evt); ); Help.add(About); Daily_Sentence.setText(每日一句); Daily_Sentence.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent evt) Daily_SentenceActionPerformed(evt); ); Help.add(Daily_Sentence); jMenuBar1.add(Help); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane(); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(Label, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE) .addGap(30, 30, 30) .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(60, 60, 60) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 新解读《GB-T 32552-2016无缝和焊接钢管(埋弧焊除外)的自动全圆周超声厚度检测》
- 乡下住房产权合同范本4篇
- 专业版办营业执照租房合同5篇
- 新解读《GB-T 31055-2014谷糙分离筛板》
- 新解读《GB-T 31207-2014机械产品再制造质量管理要求》
- 租房入学合同范本
- 汽修类员工合同范本
- 合作门窗项目合同范本
- 安全知识测试题(含答案)
- 合同签署中需要注意的法律问题
- (标准)干洗店转让合同协议书
- 2025国家民委直属事业单位招聘(48人)考前自测高频考点模拟试题及答案详解1套
- 电力电子技术(第4版)(微课版)(附任务工单)教案 徐立娟 第1-18 课程综述 -同步电机励磁电源电路
- 化学使世界变得更加绚丽多彩
- 2025年职业指导师(中级)考试试卷:职业指导师考试辅导资料
- 2025秋部编版(2024)八年级上册道德与法治 【教学课件】1.1《认识社会生活》
- 2025年重庆市高考历史试卷真题(含答案)
- 小学科学社团创客空间计划
- 临床康复一体化讲课件
- 业主信息保密管理制度
- T/CNFAGS 9-2023水煤浆气化炉协同资源化处理固体废物环境保护技术规范
评论
0/150
提交评论