- 浏览: 34149 次
- 性别:
- 来自: 北京
最新评论
-
12345678:
貌似明白了,谢谢。
swing 线程 -
山脚下的农民:
不错,有创意
java 浏览器1 -
ftp51423121:
很漂亮我是说
转:Https中安全正书导入到java的cacerts证书库中 -
xzs603:
说下原理!
转:Https中安全正书导入到java的cacerts证书库中
package com.ie;
/**
* @author Administrator
*
*/
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.CloseWindowListener;
import org.eclipse.swt.browser.LocationEvent;
import org.eclipse.swt.browser.LocationListener;
import org.eclipse.swt.browser.OpenWindowListener;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.browser.StatusTextEvent;
import org.eclipse.swt.browser.StatusTextListener;
import org.eclipse.swt.browser.WindowEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import java.awt.*;
import com.email.POPMail;
import com.email.PropertyFileOperation;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
/**
* This class implements a web browser
*/
public class WebBrowser{
// The "at rest" text of the throbber
private Label throbber;
private Button button;
private Combo url;
private Button btnStop;
private Button btnRefresh;
private Browser browser;
private Browser browser2;
private Label status;
private Button btnForward;
private Button btnBack;
private static final String AT_REST = "";
private String[] urlList = new String[256]; //最多可以保存256个url
int urlListItemCount = 0;
private ProgressBar progressBar;
private Tree tree;
private PropertyFileOperation op;
private POPMail pop;
/**
* Runs the application
*
* @param location
* the initial location to display
*/
public void run(String location) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("JAVA - Internet Explorer"); //设置窗体名称
createContents(shell, location);
shell.open();
Dimension screensize=Toolkit.getDefaultToolkit().getScreenSize();
shell.setLocation(0, 0);
shell.setSize(screensize.width-100,screensize.height-120);
// shell.setBounds(0, 0, screensize.width,screensize.height-20);
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
System.exit(0);
}
/**
* Creates the main window's contents
*
* @param shell
* the main window
* @param location
* the initial location
*/
public void createContents(Shell shell, String location) {
shell.setLayout(new FormLayout());
// Create the composite to hold the buttons and text field
Composite controls = new Composite(shell, SWT.NONE);
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
controls.setLayoutData(data);
// Create the status bar
status = new Label(shell, SWT.NONE);
data = new FormData();
data.left = new FormAttachment(0,0);
data.right = new FormAttachment(100, -100);
data.top = new FormAttachment(100,-15);
data.bottom = new FormAttachment(100, 0);
status.setLayoutData(data);
//
progressBar = new ProgressBar(shell, SWT.NONE);
data = new FormData();
data.left = new FormAttachment(status);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(100,-10);
data.bottom = new FormAttachment(100, 0);
progressBar.setLayoutData(data);
//view = new Composite(shell, SWT.NONE);
//data = new FormData();
//data.top = new FormAttachment(controls);
//data.left = new FormAttachment(0, 0);
//data.bottom = new FormAttachment(this.status);
//view.setLayoutData(data);设置树的位置
{
tree = new Tree(shell, SWT.BORDER);
data = new FormData();
data.top = new FormAttachment(controls);
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(10, 0);
data.bottom = new FormAttachment(this.progressBar);
tree.setLayoutData(data);
tree.addSelectionListener(//添加监听选择树的某一项事件
new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String tmp,server,port;
tmp=tree.getSelection()[0].getText();
if(tmp.indexOf("]")==-1)
return;
tmp=tmp.substring(1,tmp.indexOf("]"));
System.out.println(tmp);
PropertyFileOperation pfo=new PropertyFileOperation("GrainStoreServer.properties");
server=pfo.getVal("server"+tmp);
port=pfo.getVal("port"+tmp);
if(server!=null && port!=null && !server.equals("") && !port.equals(""))
if(port.equals("80"))
{
url.setText("http://"+server);
}
else
{
url.setText("http://"+server+":"+port);
}
goUrl();//打开网页
}
});
//this.setVisible(false);
// new POPMail(0);
// initVal();
}
///////// // 创建浏览器/////////////////////////////////////////////////////////
browser = new Browser(shell, SWT.BORDER);
browser.addOpenWindowListener(new OpenWindowListener() {
public void open(WindowEvent arg0) {
String urlStr = arg0.browser.getUrl();
int flag = 1;
browser.setVisible(false);
browser2.setVisible(true);
arg0.browser = browser2;
for (int i = 0; i < urlListItemCount; i++) {
if (urlList[i].equals(urlStr)) {
flag = 0;
}
}
if (flag == 1) {
urlList[urlListItemCount] = urlStr;
url.add(urlStr);
url.setText(urlStr);
urlListItemCount++;
}
}
});
data = new FormData();
data.top = new FormAttachment(controls);
data.bottom = new FormAttachment(progressBar);
data.left = new FormAttachment(this.tree);
data.right = new FormAttachment(100, 0);
browser.setLayoutData(data);
progressBar.setMaximum(100); //初始化进度条数据
progressBar.setMinimum(0);
///////// // 创建浏览器/////////////////////////////////////////////////////////
browser2 = new Browser(shell, SWT.BORDER);
browser2.addOpenWindowListener(new OpenWindowListener() {
public void open(WindowEvent arg0) {
String urlStr = arg0.browser.getUrl();
int flag = 1;
browser2.setVisible(false);
browser.setVisible(true);
arg0.browser = browser;
for (int i = 0; i < urlListItemCount; i++) {
if (urlList[i].equals(urlStr)) {
flag = 0;
}
}
if (flag == 1) {
urlList[urlListItemCount] = urlStr;
url.add(urlStr);
url.setText(urlStr);
urlListItemCount++;
}
}
});
data = new FormData();
data.right = new FormAttachment(1000, 1000, 0);
browser2.setLayoutData(data);
// Create the controls and wire them to the browser
controls.setLayout(new GridLayout(7, false));
// Create the back button
btnBack = new Button(controls, SWT.PUSH);
btnBack.setText("后退");
btnBack.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
browser.back();
}
});
// Create the forward button
btnForward = new Button(controls, SWT.PUSH);
btnForward.setText("前进");
btnForward.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
browser.forward();
}
});
// Create the refresh button
btnRefresh = new Button(controls, SWT.PUSH);
btnRefresh.setText("刷新");
btnRefresh.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
browser.refresh();
}
});
// Create the stop button
btnStop = new Button(controls, SWT.PUSH);
btnStop.setText("停止");
btnStop.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
browser.stop();
}
});
// Create the address entry field and set focus to it
url = new Combo(controls, SWT.ARROW_DOWN);
url.setLayoutData(new GridData(296, SWT.DEFAULT));
url.setSize(600, url.getSize().y);
url.setFocus();
// Create the go button
button = new Button(controls, SWT.PUSH);
button.setText("转到");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
goUrl();
}
});
// Create the animated "throbber"
throbber = new Label(controls, SWT.NONE);
throbber.setText(AT_REST);
// Allow users to hit enter to go to the typed URL
shell.setDefaultButton(button);
// Add event handlers
browser.addCloseWindowListener(new AdvancedCloseWindowListener());
browser.addLocationListener(new AdvancedLocationListener(url));
browser.addProgressListener(new AdvancedProgressListener(throbber));
browser.addStatusTextListener(new AdvancedStatusTextListener(status));
// Go to the initial URL
if (location != null) {
browser.setUrl(location);
}
new POPMail(0);
this.initVal();
}
/**
* This class implements a CloseWindowListener for TestBrowser
*/
class AdvancedCloseWindowListener implements CloseWindowListener {
/**
* Called when the parent window should be closed
*/
public void close(WindowEvent event) {
// Close the parent window
((Browser) event.widget).getShell().close();
}
}
/**
* This class implements a LocationListener for TestBrowser
*/
class AdvancedLocationListener implements LocationListener {
// The address text box to update
private Combo location;
/**
* Constructs an AdvancedLocationListener
*
* @param text
* the address text box to update
*/
public AdvancedLocationListener(Combo text) {
// Store the address box for updates
location = text;
}
/**
* Called before the location changes
*
* @param event
* the event
*/
public void changing(LocationEvent event) {
// Show the location that's loading
//location.setText("Loading " + event.location + "...");
location.setText(event.location);
}
/**
* Called after the location changes
*
* @param event
* the event
*/
public void changed(LocationEvent event) {
// Show the loaded location
location.setText(event.location);
}
}
/**
* This class implements a ProgressListener for TestBrowser
*/
class AdvancedProgressListener implements ProgressListener {
// The label on which to report progress
//private Label progress;
/**
* Constructs an AdvancedProgressListener
*
* @param label
* the label on which to report progress
*/
public AdvancedProgressListener(Label label) {
// Store the label on which to report updates
// progress = label;
}
/**
* Called when progress is made
*
* @param event
* the event
*/
public void changed(ProgressEvent event) {
// Avoid divide-by-zero
if (event.total != 0) {
// Calculate a percentage and display it
int percent = (int) (event.current / event.total)*100;
//progress.setText(percent + "%");
progressBar.setSelection(percent);//设置网页显示进度
} //else {
// Since we can't calculate a percent, show confusion :-)
// progress.setText("");
// }
}
/**
* Called when load is complete
*
* @param event
* the event
*/
public void completed(ProgressEvent event) {
// Reset to the "at rest" message
//progress.setText(AT_REST);
}
}
/**
* This class implements a StatusTextListener for TestBrowser
*/
class AdvancedStatusTextListener implements StatusTextListener {
// The label on which to report status
private Label status;
/**
* Constructs an AdvancedStatusTextListener
*
* @param label
* the label on which to report status
*/
public AdvancedStatusTextListener(Label label) {
// Store the label on which to report status
status = label;
}
/**
* Called when the status changes
*
* @param event
* the event
*/
public void changed(StatusTextEvent event) {
// Report the status
status.setText(event.text);
}
}
//解决编码转换
public String getStr(String str)
{
try{
String temp_p = str;
byte [] temp_t = temp_p.getBytes("ISO8859-1");
String temp = new String(temp_t);
return temp;
}
catch(Exception e){
return "null";
}
}
public void initVal()
{
///////////////
op=new PropertyFileOperation("MailServer.properties");//读取邮箱配置
////////////////重邮箱更新粮库服务器信息/////////////////////////////////////////////////////
int num=Integer.parseInt(op.getVal("num"));
//pop=new POPMail(op.getVal("server"),op.getVal("user"),op.getVal("pass"),num,op.getVal("from"));
/////////////加载树数据,粮库地址///////////////////////////////////////////////////////
PropertyFileOperation pfo=new PropertyFileOperation("Tree.properties");
for(int i=1;i<=num;i++)
{
String str=pfo.getVal("server"+i+"");
if(str!=null && !str.equals(""))
{
TreeItem treeItem = new TreeItem(tree, SWT.NONE);
treeItem.setText(getStr(pfo.getVal("server"+i+"")));
}
}
}
public void goUrl()
{
String urlStr = url.getText();
int flag = 1;
browser.setUrl(urlStr);
for (int i = 0; i < urlListItemCount; i++) {
if (urlList[i].equals(urlStr)) {
flag = 0;
}
}
if (flag == 1) {
urlList[urlListItemCount] = urlStr;
url.add(urlStr);
urlListItemCount++;
}
}
/**
* The application entry point
*
* @param args
* the command line arguments
*/
public static void main(String[] args) {
//new POPMail(0);
new WebBrowser().run(args.length == 0 ? "about:blank" : args[0]);
}
}
package com.ie;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class MailServer extends javax.swing.JDialog {
/**
* Auto-generated main method to display this JDialog
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame();
MailServer inst = new MailServer(frame);
inst.setVisible(true);
}
});
}
public MailServer(JFrame frame) {
super(frame);
initGUI();
}
private void initGUI() {
try {
setSize(400, 300);
} catch (Exception e) {
e.printStackTrace();
}
}
}
相关推荐
总的来说,"Java浏览器"项目不仅展示了Java在创建复杂应用程序时的能力,还为Java开发者提供了一个实践多线程、网络编程、UI设计和安全策略的绝佳案例。通过深入研究和改进这样的项目,Java开发者可以提升自己的技能...
标题中的“超漂亮的纯JAVA浏览器”指的是一个基于Java语言开发的网页浏览应用,它具有出色的用户界面设计,提供了良好的视觉体验。这样的浏览器通常利用Java的跨平台特性,可以在多种操作系统上运行,包括Windows、...
下面我们将深入探讨Java浏览器的核心知识点。 1. JavaFX:JavaFX是用于构建桌面、移动和嵌入式系统的现代Java GUI应用程序的框架。在Java浏览器的实现中,JavaFX可能被用作渲染引擎,提供图形用户界面组件,如按钮...
Java浏览器是一种基于Java编程语言开发的轻量级应用程序,它允许用户浏览网页并执行基本的互联网功能。在MyEclipse环境中开发的Java浏览器项目,利用了Java的强大功能和跨平台特性,为用户提供了一种不同于传统Web...
Java浏览器课程设计是一门深入探讨如何使用Java编程语言构建一个功能完备的Web浏览器的实践性课程。这个项目旨在让学生理解网络通信的基本原理,掌握Java GUI(图形用户界面)设计,并了解浏览器背后的复杂工作流程...
【标题】:“Java浏览器课件及程序”是一个学习资源包,专为初学者提供Java编程与浏览器相关的知识。这个资源包包含了一系列文档和课件,旨在帮助初入Java开发领域的人快速掌握基础知识。 【描述】:“对入门级java...
压缩包中的文件名"java浏览器调用ie内核-1、java浏览器调用ie内核-简单"可能代表了实现此功能的不同版本或步骤。"1"可能是基础实现,而"简单"可能是简化后的版本。这些文件可能包含Java源代码、配置文件或者相关的...
Java浏览器控件是一种技术,允许Java应用程序嵌入和交互与Web内容,类似于在桌面应用中使用Web浏览器的功能。本主题将深入探讨通过JNI(Java Native Interface)实现的Java浏览器控件,这是一种Java与本地操作系统...
UC Java浏览器是一款专为Java平台设计的移动浏览器,它提供了高效、便捷的互联网浏览体验。这个集合包含了UC浏览器的各个历史版本,对于开发者和用户来说,这是一个宝贵的资源库,可以追溯浏览器的发展历程,或者在...
【JAVA浏览器小实例】是一个适合课程设计的简单项目,它为初学者提供了了解和实践JAVA编程语言在网络应用方面的基础知识。这个实例通常会涵盖以下几个关键知识点: 1. **JAVA基础**:首先,理解JAVA编程的基本语法...
Java实现内置浏览器是一种技术实践,它允许开发者在Java应用程序中集成一个Web浏览器组件,使得用户可以在应用程序内部浏览网页,提供类似桌面应用的体验。这种方式通常使用JavaFX或Swing库来构建用户界面,并通过...
"JAVA浏览器" 本文将围绕JAVA浏览器的开发和设计展开讨论,涵盖了浏览器的基本功能、面向对象编程、网络编程方法、模型建立、网页浏览器设计等多个方面的知识点。 一、浏览器的基本功能 浏览器是我们在互联网上...
1. 用户通过Java浏览器访问一个包含Java应用的网页。 2. 浏览器检测到页面中的Java代码,并启动Java插件或Java Web Start。 3. Java虚拟机(JVM)被加载到内存中,解析和执行Java字节码。 4. Java应用在浏览器窗口中...
里面包含xulrunner java浏览器 swing浏览器 awt浏览器 所有工程源码 均包含在里面 jar一律齐全 不像其他分享源码的作者 不分享jar包出来 导致参考源码需要找很多jar 无疑给参考者浪费了很多宝贵时间,如果大 家觉得...
Java浏览器是一种基于Java技术实现的网络浏览工具,它利用Java平台的强大功能,提供了一种不同于传统Web浏览器的体验。在Java编程环境中,开发者可以利用Java的跨平台特性,创建一个能够在任何支持Java运行环境的...
java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java图片浏览器java...
Java浏览器是Java编程环境中用于显示和交互Web内容的软件组件,它允许开发者在Java应用程序中嵌入网页浏览功能。在本资源中,我们关注的是使用Swing库来实现这一目标,Swing是Java Foundation Classes (JFC)的一部分...
4. **JavaScript执行**:Java浏览器需要支持JavaScript,这通常通过JavaScript引擎实现,比如开源的Rhino或Nashorn。JavaScript引擎负责解释和执行JS代码,与网页交互,实现动态效果和用户交互。 5. **渲染引擎**:...
2. JavaScript引擎:Java浏览器通常会包含一个JavaScript引擎,如OpenJDK的HotSpot或Mozilla的Rhino,用于执行网页中的JavaScript代码。JavaScript引擎使浏览器能够与用户交互、处理动态内容和执行服务器请求。 3. ...
标签"java-cef"、"Java浏览器"和"java谷歌"暗示了这个项目是关于Java环境下利用CEF实现的浏览器功能,特别强调了与谷歌技术的结合。因此,开发者应当熟悉Java编程,了解CEF框架,以及谷歌的Web技术标准。在实践中,...