boxCenter.javaimport java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.TrayIcon;import javax.swing.JFrame;import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;public class boxCenter extends JFrame {
public TrayIcon ti;
public static void main(String[] args) {
boxCenter bc = new boxCenter();
bc.getTest("test");
}
public static void getTest(String name) {
boxCenter frame = new boxCenter();
System.setProperty("sun.awt.xembedserver", "true");
Display display = Display.getDefault();
Canvas canvas = new Canvas();
frame.add(canvas, BorderLayout.CENTER);
frame.pack();
final Shell shell = SWT_AWT.new_Shell(display, canvas);
shell.setLayout(new FillLayout(SWT.DOWN));
final Browser browser = new Browser(shell, SWT.EMBEDDED);
browser.setUrl("http://www.baidu.com");
browser.setVisible(true);
shell.open();
frame.setSize(400, 300);
frame.setVisible(true);
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Login1.java
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JOptionPane;
import javax.swing.BoxLayout;
import javax.swing.Box;
import javax.swing.BorderFactory;public class Login1 extends boxCenter {
public static String s = null; public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
boxCenter bc = new boxCenter();
bc.getTest(s);
} }); } public static void createAndShowGUI() {
JFrame mainFrame = new JFrame();
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setBounds(250, 250, 400, 300);
mainFrame.setVisible(false); usernameField = new JTextField(10);
passwordField = new JPasswordField(10); Object[] options = { "登录", "取消" };
int i = JOptionPane.showOptionDialog(null, createLoginPanel(), "登录信息",
JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null,
options, options[0]);
if (i == 0) {
String username = usernameField.getText();
String password = passwordField.getText();
if (!username.equals("") && !password.equals("")) {
s = username;
} else {
JOptionPane.showMessageDialog(null, "用户名和密码不能为空", "提示",
JOptionPane.WARNING_MESSAGE);
System.exit(1);
}
} else
System.exit(0); } static JPanel createLoginPanel() {
JPanel ret = new JPanel(); JPanel usernamePanel = new JPanel();
usernamePanel.add(new JLabel("用户名:", JLabel.RIGHT));
usernamePanel.add(usernameField);
JPanel passwordPanel = new JPanel();
passwordPanel.add(new JLabel("密  码:", JLabel.RIGHT));
passwordPanel.add(passwordField); Box box = new Box(BoxLayout.Y_AXIS);
box.add(usernamePanel);
box.add(passwordPanel); ret.add(box); ret.setBorder(BorderFactory.createTitledBorder(BorderFactory
.createLineBorder(new Color(244, 144, 44)), "填写登录信息"));
return ret;
} static JFrame mainFrame = null;
static JTextField usernameField = null;
static JPasswordField passwordField = null;
}boxCenter.java用的JAR包 org.eclipse.swt.win32.win32.x86_3.3.0.v3346.jar谢谢各位!我q:706380 可提源码.
在等答啊大侠们拜托啦。。
javabrowser