資源簡介
使用java編寫的基于IE內核多標簽式的網頁瀏覽器

代碼片段和文件信息
package?liou;
import?org.eclipse.swt.SWT;
import?org.eclipse.swt.browser.*;
import?org.eclipse.swt.events.*;
import?org.eclipse.swt.layout.*;
import?org.eclipse.swt.widgets.*;
import?javax.swing.*;
import?java.awt.Component;
import?java.io.*;?
import?java.io.InputStream;
import?java.net.*;
import?javax.swing.JFileChooser;
import?javax.swing.JOptionPane;
public?class?AGBrowser?extends?Jframe?{
//基于IE內核標簽式的瀏覽器
JFileChooser?chooser1=new?JFileChooser?();//另存為用戶選擇文件
?private?volatile?String?newUrl?=?null;//?最新輸入的鏈接
?private?volatile?boolean?loadCompleted?=?false;//表示當前頁面完全導入
?public?String?htmlSource;?//存儲源代碼
?private?volatile?boolean?openNewItem=false;//表示新的頁面在新窗口中打開
?
?/*
??*?瀏覽器的當前標簽參數
??*/
?JTextField?jurl?=?new?JTextField?(80);
?private?TabItem?tabItem_now;//當前標簽項
?
?private?Browser?browser_now;//當前功能瀏覽器
?/*
??*?瀏覽器設置參數
??*/
?private?String?homePage?=?“about:blank“;//?瀏覽器的首頁
?/*
??*?瀏覽器外形布置
??*/
?
?private?Button?button_file;//查看源代碼
?private?Button?button_edi;//另存為
?private?Button?button_zhuye;//修改主頁
?private?Button?button_zy;//主頁按鈕
?private?Button?button_back;//后退按鈕
?private?Button?button_forward;//向前按鈕
?private?Button?button_go;//前進按鈕
?private?Button?button_stop;//停止按鈕
?private?Combo?combo_address;//?地址欄
?private?Browser?browser_default?=?null;//?瀏覽窗口
?private?ProgressBar?progressBar_status;//?網頁打開進度表,即頁面導入情況欄
?private?Label?label_status;//?最終網頁打開過程顯示
?private?TabFolder?tabFolder;//?Browser的容器
?private?Composite?composite_too;//?工具欄區域
?private?Composite?composite_tool;
//?private?Composite?composite_too2;
?private?Composite?composite_browser;//?瀏覽窗口區域
?private?Composite?composite_status;//?狀態欄區域
?protected?Display?display;
?protected?Shell?shell_default;
?/**
??*?Launch?the?application
??*?
??*?@param?args
??*/
?AGBrowser(){
?try?{File?f?=?new?File(“books.txt“);//?主頁地址存放文件
??FileInputStream?in?=?new?FileInputStream(f);
DataInputStream?dis?=?new?DataInputStream(in);
homePage?=?dis.readUTF();//System.out.println(homePage);
}catch?(IOException?e)?{
System.out.println(e.getMessage());}}
?public?static?void?main(String[]?args)?{
??try?{
???AGBrowser?window?=?new?AGBrowser();
???window.open();
??}?catch?(Exception?e)?{
???e.printStackTrace();
??}
?}
?/**
??*?Open?the?window
??*/
?public?void?open()?{
??display?=?Display.getDefault();
??shell_default?=?new?Shell(display);
??createContents();
??shell_default.open();
??shell_default.layout();
??while?(!shell_default.isDisposed())?{
???if?(!display.readAndDispatch())
????display.sleep();
??}
?}
?/**
??*?Create?contents?of?the?window
??*/
?protected?void?createContents()?{
??shell_default.setSize(649?448);
??shell_default.setText(“瀏覽器“);
??GridLayout?gl_shell?=?new?GridLayout();
??gl_shell.marginWidth?=?0;//?組件與容器邊緣的水平距離
??gl_shell.marginHeight?=?0;//?組件與容器邊緣的垂直距離
??gl_shell.horizontalSpacing?=?0;//?組件之間的水平距離
??gl_shell.verticalSpacing?=?0;//?組件之間的垂直距離
??sh
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????22228??2010-12-18?22:23??liou\AGBrowser.java
?????文件???????2786??2010-12-03?15:28??liou\ViewSourcefr
?????目錄??????????0??2010-12-18?21:18??liou
-----------?---------??----------?-----??----
????????????????25014????????????????????3
- 上一篇:java實現多文件異步上傳
- 下一篇:基于java銀行管理系統的設計.doc
評論
共有 條評論