java SWT 如何实现两个窗体之间的数据传递?
没有呢称了 2014-03-29 03:05:02 我用eclipse创建了两个窗体,想将窗体1里的text输入的帐号获取,然后在第二个窗口可以text_1可以调用到这个帐号,应该怎么做?小白第一次接触eclipse,希望大神来帮帮忙。谢谢
ackage 1;
import org.eclipse.swt.graphics.Rectangle;
public class huuh {
protected Shell shell;
private Text text;
/**
* Launch the application.
* @param args
*/
public static void main(String[] args) {
try {
huuh window = new huuh();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
/**
* Create contents of the window.
*/
protected void createContents() {
shell = new Shell();
shell.setSize(450, 300);
shell.setText("SWT Application");
Label lblNewLabel = new Label(shell, SWT.NONE);
lblNewLabel.setBounds(36, 42, 102, 26);
lblNewLabel.setText("\u767B\u5F55");
text = new Text(shell, SWT.BORDER);
text.setBounds(180, 45, 181, 33);
}
}
第二个:
package 2;
import org.eclipse.swt.widgets.Display;
public class you {
protected Shell shell;
private Text text;
/**
* Launch the application.
* @param args
*/
public static void main(String[] args) {
try {
you window = new you();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
/**
* Create contents of the window.
*/
protected void createContents() {
shell = new Shell();
shell.setSize(450, 300);
shell.setText("SWT Application");
text = new Text(shell, SWT.BORDER);
text.setBounds(117, 34, 200, 47);
}
}
怎么实现第一个text填写的内容成功获取传递给第二个里面的text,,