SWT(JFace) 简易浏览器简易浏览器 制作实现代码第制作实现代码第1/2页页
代码如下:
BrowserExample.java
代码如下:
package swt_jface.demo5;
import java.text.MessageFormat;
import java.util.MissingResourceException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTError;
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.TitleEvent;
import org.eclipse.swt.browser.TitleListener;
import org.eclipse.swt.browser.VisibilityWindowListener;
import org.eclipse.swt.browser.WindowEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
public class BrowserExample {
//static ResourceBundle resourceBundle = ResourceBundle.getBundle(“examples_browser”);
int index;
boolean busy;
Image images[];
Text location;
Browser browser;
static final String[] imageLocations = {
“eclipse01.bmp”, “eclipse02.bmp”, “eclipse03.bmp”, “eclipse04.bmp”, “eclipse05.bmp”,
“eclipse06.bmp”, “eclipse07.bmp”, “eclipse08.bmp”, “eclipse09.bmp”, “eclipse10.bmp”,
“eclipse11.bmp”, “eclipse12.bmp”,};
static final String iconLocation = “document.gif”;
public BrowserExample(Composite parent) {
final Display display = parent.getDisplay();
FormLayout layout = new FormLayout();
parent.setLayout(layout);
ToolBar toolbar = new ToolBar(parent, SWT.NONE);
final ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
itemBack.setText(getResourceString(“Back”));
final ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
itemForward.setText(getResourceString(“Forward”));
final ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
itemStop.setText(getResourceString(“Stop”));
final ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
itemRefresh.setText(getResourceString(“Refresh”));
final ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);