📄 simplebrowserwindow.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: SimpleBrowserWindow.java
package org.gudy.azureus2.ui.swt.shells;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.components.shell.ShellFactory;
public class SimpleBrowserWindow
{
private Shell shell;
private Browser browser;
public SimpleBrowserWindow(Shell parent, String url, double wPct, double hPct, boolean allowResize,
boolean isModal)
{
if (parent == null)
{
init(parent, url, 0, 0, allowResize, isModal);
} else
{
Rectangle clientArea = parent.getClientArea();
init(parent, url, (int)((double)clientArea.width * wPct), (int)((double)clientArea.height * hPct), allowResize, isModal);
}
}
public SimpleBrowserWindow(Shell parent, String url, int w, int h, boolean allowResize, boolean isModal)
{
init(parent, url, w, h, allowResize, isModal);
}
private void init(Shell parent, String url, int w, int h, boolean allowResize, boolean isModal)
{
if (parent == null)
parent = Utils.findAnyShell();
int style = 2144;
if (allowResize)
style |= 0x10;
if (isModal)
style |= 0x10000;
shell = ShellFactory.createShell(parent, style);
shell.setLayout(new FillLayout());
Utils.setShellIcon(shell);
try
{
browser = new Browser(shell, Utils.getInitialBrowserStyle(0));
shell.addListener(21, new Listener() {
final SimpleBrowserWindow this$0;
public void handleEvent(Event arg0)
{
try
{
if (browser != null)
{
browser.setUrl("about:blank");
browser.setVisible(false);
}
}
catch (Throwable e) { }
}
{
this$0 = SimpleBrowserWindow.this;
super();
}
});
}
catch (Throwable t)
{
shell.dispose();
return;
}
browser.addProgressListener(new ProgressListener() {
final SimpleBrowserWindow this$0;
public void completed(ProgressEvent event)
{
shell.open();
}
public void changed(ProgressEvent progressevent)
{
}
{
this$0 = SimpleBrowserWindow.this;
super();
}
});
browser.addCloseWindowListener(new CloseWindowListener() {
final SimpleBrowserWindow this$0;
public void close(WindowEvent event)
{
shell.dispose();
}
{
this$0 = SimpleBrowserWindow.this;
super();
}
});
browser.addTitleListener(new TitleListener() {
final SimpleBrowserWindow this$0;
public void changed(TitleEvent event)
{
shell.setText(event.title);
}
{
this$0 = SimpleBrowserWindow.this;
super();
}
});
if (w > 0 && h > 0)
shell.setSize(w, h);
Utils.centerWindowRelativeTo(shell, parent);
browser.setUrl(url);
browser.setData("StartURL", url);
}
public void waitUntilClosed()
{
Display display = shell.getDisplay();
do
{
if (shell.isDisposed())
break;
if (!display.readAndDispatch())
display.sleep();
} while (true);
}
public static void main(String args[])
{
Display display = new Display();
Shell shell = new Shell(display, 2144);
shell.setSize(800, 600);
new SimpleBrowserWindow(shell, "http://google.com", 0.80000000000000004D, 0.5D, true, false);
shell.open();
do
{
if (shell.isDisposed())
break;
if (!display.readAndDispatch())
display.sleep();
} while (true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -