java浏览器源码_java-内嵌浏览器源码

1 importorg.eclipse.swt.SWT;2 importorg.eclipse.swt.browser.Browser;3 importorg.eclipse.swt.browser.CloseWindowListener;4 importorg.eclipse.swt.browser.LocationEvent;5 importorg.eclipse.swt.browser.LocationListener;6 importorg.eclipse.swt.browser.OpenWindowListener;7 importorg.eclipse.swt.browser.ProgressEvent;8 importorg.eclipse.swt.browser.ProgressListener;9 importorg.eclipse.swt.browser.StatusTextEvent;10 importorg.eclipse.swt.browser.StatusTextListener;11 importorg.eclipse.swt.browser.WindowEvent;12 importorg.eclipse.swt.events.SelectionAdapter;13 importorg.eclipse.swt.events.SelectionEvent;14 importorg.eclipse.swt.layout.FormAttachment;15 importorg.eclipse.swt.layout.FormData;16 importorg.eclipse.swt.layout.FormLayout;17 importorg.eclipse.swt.layout.GridData;18 importorg.eclipse.swt.layout.GridLayout;19 importorg.eclipse.swt.widgets.Button;20 importorg.eclipse.swt.widgets.Combo;21 importorg.eclipse.swt.widgets.Composite;22 importorg.eclipse.swt.widgets.Display;23 importorg.eclipse.swt.widgets.Label;24 importorg.eclipse.swt.widgets.Shell;25 26 /**27 * This class implements a web browser28 */29 publicclassTestBrowser {30 //The "at rest" text of the throbber31 32 privateLabel throbber;33 34 privateButton button;35 36 privateCombo url;37 38 privateButton button_4;39 40 privateButton button_3;41 42 privateBrowser browser;43 44 privateBrowser browser2;45 46 privateLabel status;47 48 privateButton button_2;49 50 privateButton button_1;51 52 privatestaticfinalString AT_REST="Ready";53 54 privateString[] urlList=newString[256];55 56 inturlListItemCount=0;57 58 /**59 * Runs the application60 *61 *@paramlocation62 * the initial location to display63 */64 publicvoidrun(String location) {65 Display display=newDisplay();66 Shell shell=newShell(display);67 shell.setText("Advanced Browser");68 createContents(shell, location);69 shell.open();70 while(!shell.isDisposed()) {71 if(!display.readAndDispatch()) {72 display.sleep();73 }74 }75 display.dispose();76 }77 78 /**79 * Creates the main window's contents80 *81 *@paramshell82 * the main window83 *@paramlocation84 * the initial location85 */86 publicvoidcreateContents(Shell shell, String location) {87 shell.setLayout(newFormLayout());88 89 //Create the composite to hold the buttons and text field90 91 Composite controls=newComposite(shell, SWT.NONE);92 FormData data=newFormData();93 data.top=newFormAttachment(0,0);94 data.left=newFormAttachment(0,0);95 data.right=newFormAttachment(100,0);96 controls.setLayoutData(data);97 98 //Create the status bar99 100 status=newLabel(shell, SWT.NONE);101 data=newFormData();102 data.left=newFormAttachment(0,0);103 data.right=newFormAttachment(100,0);104 data.bottom=newFormAttachment(100,0);105 status.setLayoutData(data);106 107 //Create the web browser108 109 browser=newBrowser(shell, SWT.BORDER);110 browser.addOpenWindowListener(newOpenWindowListener() {111 publicvoidopen(WindowEvent arg0) {112 String urlStr=arg0.browser.getUrl();113 intflag=1;114 browser.setVisible(false);115 browser2.setVisible(true);116 arg0.browser=browser2;117 for(inti=0; i

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值