- 浏览: 208504 次
- 性别:
- 来自: sdf
文章分类
最新评论
-
scd01234:
可以运行了,感谢师兄的慈悲加护!阿弥陀佛
基于eclipse swt做java浏览器内嵌等功能 -
seeyoula:
11
ie8 iframe支持问题 -
poorzerg:
很好,可以跑..谢谢了,我参考下..
基于eclipse swt做java浏览器内嵌等功能 -
landy8530:
验证网址那个方法,我直接输入sjkdasj这样的字符串返回也是 ...
js数据验证、js email验证、js url验证、js长度验证、js数字验证等 -
青春的、脚步:
表示运行不了 怎么回事 一模一样哦
mysql循环插入数据
swt-3.5M4-win32-win32-x86.zip 包下载地址:
http://download.csdn.net/source/921856
csdn上有些朋友说我这个是骗人的包。我无语。几个dome,你们自己去看吧。别不会用就说我人品有问题。
import java.util.ArrayList; import org.eclipse.swt.SWT; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.browser.OpenWindowListener; import org.eclipse.swt.browser.VisibilityWindowListener; import org.eclipse.swt.browser.WindowEvent; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; public class BrowserTest1 { static final ArrayList urls = new ArrayList(); // @jve:decl-index=0: static boolean canRemove = false; public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("jog36行业招聘"); Image image = new Image(shell.getDisplay(), "Favicon.ico"); shell.setImage(image); shell.setLayout(new FillLayout()); Browser browser = new Browser(shell, SWT.NONE); initialize(display, browser); shell.open(); browser.setUrl("www.job36.com"); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } static void initialize(final Display display, Browser browser) { browser.addListener(SWT.MouseDown, new Listener() { public void handleEvent(Event event) { System.out.println("event.time:" + event.time); } }); browser.addOpenWindowListener(new OpenWindowListener() { public void open(WindowEvent event) { // Embed the new window final Shell shell = new Shell(display); shell.setText("New Window"); shell.setLayout(new FillLayout()); final Browser browser = new Browser(shell, SWT.NONE); initialize(display, browser); event.browser = browser; event.display.asyncExec(new Runnable() { public void run() { String url = browser.getUrl(); System.out.println(url); System.out.println(browser.getText()); if (urls.contains(url)){ //flag to chek if the window is closed automatic canRemove = false; shell.close(); } else{ canRemove = true; urls.add(url); } } }); } }); browser.addVisibilityWindowListener(new VisibilityWindowListener() { public void hide(WindowEvent event) { Browser browser = (Browser) event.widget; Shell shell = browser.getShell(); shell.setVisible(false); } public void show(WindowEvent event) { Browser browser = (Browser) event.widget; Shell shell = browser.getShell(); if (event.location != null) shell.setLocation(event.location); if (event.size != null) { Point size = event.size; shell.setSize(shell.computeSize(size.x, size.y)); } if (event.addressBar || event.menuBar || event.statusBar || event.toolBar) { // Create widgets for the address bar, menu bar, status bar and/or tool bar // leave enough space in the Shell to accomodate a Browser of the size // given by event.size } shell.open(); } }); browser.addDisposeListener(new DisposeListener(){ public void widgetDisposed(DisposeEvent event){ Browser browser = (Browser) event.widget; if (canRemove) urls.remove(browser.getUrl()); Shell shell = browser.getShell(); // shell.close(); } }); } }
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.Shell; /** * This class implements a web browser */ public class TestBrowser { // The "at rest" text of the throbber private Label throbber; private Button button; private Combo url; private Button button_stop; private Button button_refresh; private Browser browser; private Browser browser2; private Label status; private Button button_forward; private Button button_back; private static final String AT_REST = "Ready"; private String[] urlList = new String[256]; int urlListItemCount = 0; /** * 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("Job36 行业招聘网 CRM系统"); createContents(shell, location); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } /** * 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, 0); data.bottom = new FormAttachment(100, 0); status.setLayoutData(data); // Create the web browser browser = new Browser(shell, SWT.BORDER); browser.addOpenWindowListener(new OpenWindowListener() { public void open(WindowEvent event) { Browser browsertest = (Browser)event.widget; final Shell shell = browser.getShell(); System.out.println(null==browsertest?"为null":browsertest.getUrl()); // String urlStr = event.browser.getUrl(); // int flag = 1; // browser.setVisible(false); // browser2.setVisible(true); // event.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(status); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); browser.setLayoutData(data); // Create the web browser 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.top = new FormAttachment(controls); data.bottom = new FormAttachment(status); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(100, 0); browser2.setLayoutData(data); // Create the controls and wire them to the browser controls.setLayout(new GridLayout(7, false)); // Create the back button button_back = new Button(controls, SWT.PUSH); button_back.setText("后退"); button_back.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.back(); } }); // Create the forward button button_forward = new Button(controls, SWT.PUSH); button_forward.setText("前进"); button_forward.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.forward(); } }); // Create the refresh button button_refresh = new Button(controls, SWT.PUSH); button_refresh.setText("刷新"); button_refresh.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { browser.refresh(); } }); // Create the stop button button_stop = new Button(controls, SWT.PUSH); button_stop.setText("停止"); button_stop.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("Go"); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { 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++; } } }); // 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); } } /** * 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("加载 " + 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); progress.setText(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); } } /** * The application entry point * * @param args * the command line arguments */ public static void main(String[] args) { new TestBrowser().run(args.length == 0 ? null : args[0]); } }
评论
5 楼
scd01234
2014-03-21
可以运行了,感谢师兄的慈悲加护!阿弥陀佛
4 楼
poorzerg
2012-11-22
很好,可以跑..谢谢了,我参考下..
3 楼
wangzi6hao
2011-12-13
151813483 写道
挺好的,谢谢。
你够用就行,好久没有看过了,之前写的。多的功能你要自己看api了。呵呵。
2 楼
151813483
2011-10-28
挺好的,谢谢。
1 楼
epinszteinic
2011-08-18
不是dome,是demo
发表评论
-
文件上传类
2009-11-27 22:40 801package com.job36.util; impo ... -
javamail发送html邮件
2009-11-27 22:38 1632import java.io.BufferedReader; ... -
java 将网页转为jpg
2009-11-27 22:37 2382package com.job36.util.pdf; ... -
java压缩图片类
2009-11-27 22:36 1760import java.awt.Color; import ... -
java读写Cookie
2009-11-27 22:36 1761import java.io.UnsupportedEncod ... -
java分页
2009-11-27 22:35 1086import java.util.List; ... -
proxool配置jtds
2009-11-27 22:26 1239jdbc-0.proxool.alias=DBPool jd ... -
proxool配置mysql proxool配置mysql乱码
2009-11-27 22:20 1332jdbc-0.proxool.alias=DBPool jd ... -
proxool配置mysql proxool配置mysql乱码
2009-11-27 22:19 1528jdbc-0.proxool.alias=DBPool jd ... -
Pager Tag Library中文乱码
2009-11-27 22:19 1476昨天在做Pager Tag Library分页时碰到了乱码. ... -
java JDBC连接数据库
2009-11-27 22:12 9922009-09-17 22:06 package com. ... -
java filter做字符串过滤 java处理乱码
2009-11-27 22:12 14772009-09-17 22:09 package com. ... -
java filter做简单登录过滤
2009-11-27 22:11 15232009-09-17 22:11 package com. ... -
proxool数据连接池 java代码
2009-11-27 22:10 12562009-09-17 22:16 package com. ... -
java多线程模拟读不重复的数据 java多线程按顺序读数据
2009-11-27 22:06 1526以下内容是根据本人的一些业务逻辑来做的一个dome,应该有很多 ...
相关推荐
Java内嵌浏览器eclipse.swt插件版 swt-3.5M4-win32-win32-x86 eclipse.swt 源码,jar包 demo eclipse工程实例
本程序是基于Eclipse SWT的界面开发,实现了一个基本的日历界面,有助于初学者掌握基本的SWT语法
java eclipse swt word教程
org.eclipse.swt.SWT.class org.eclipse.swt.SWTError.class org.eclipse.swt.SWTException.class org.eclipse.swt.accessibility.ACC.class org.eclipse.swt.accessibility.Accessible.class org.eclipse.swt....
这是用JAVA基于SWT编写的多标签浏览器,可以添加书签,包括 源码(用eclipse直接载入),SWT包
DJNativeSwing-SWT组件-Java GUI中内嵌浏览器相关JAR包
《Eclipse SWT/Jface核心应用》全面介绍了SWT、JFace和RCP的相关知识。全书共分5篇,第1篇介绍了SWT产生的背景以及SWT的一些基本概念和基础知识。第2篇介绍了SWT基本控件的使用,以及事件处理、布局等SWT基本知识的...
Eclipse SWT Designer安装教程
eclipseSwt swt-3.5M4-win32-win32-x86.zip 包含browser包内容,可以做java浏览器内嵌等功能包
Eclipse SWT 3.106 arm 版 适配 uos 飞腾等国产操作系统 定制eclipse rcp应用神器
Eclipse SWT/JFace 核心应用 带书签 Eclipse SWT/JFace
Eclipse SWT JFace核心应用 Eclipse SWT JFace核心应用
Eclipse SWT JFace核心应用 PDF
org.eclipse.swt 相关jar包,JAVA调用火狐内核制作浏览器教程中所需,供各位下载,可在我的博客中查看详细用法。
Eclipse SWT/JFace核心应用
JAVA ECLIPSE SWT Designer注册机
Eclipse SWT 4.4 API 文档,根据官方zip源码包编译而成
eclipse swt/jface核心应用
Eclipse中SWT插件的安装Eclipse中SWT插件的安装
eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse swt eclipse ...