SWT 怎么得到文本框里的值 求教
浮云若水 2012-02-07 03:12:06 import org.eclipse.jface.action.MenuManager;
public class test extends ApplicationWindow {
private Text Nub1;
private Text Nub2;
private Text Count;
/**
* Create the application window.
*/
public test() {
super(null);
createActions();
addToolBar(SWT.FLAT | SWT.WRAP);
addMenuBar();
addStatusLine();
}
/**
* Create contents of the application window.
* @param parent
*/
@Override
protected Control createContents(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
Nub1 = new Text(container, SWT.BORDER);
Nub1.setBounds(28, 23, 73, 23);
Label label = new Label(container, SWT.NONE);
label.setAlignment(SWT.CENTER);
label.setBounds(109, 26, 38, 17);
label.setText("+");
Nub2 = new Text(container, SWT.BORDER);
Nub2.setBounds(153, 23, 73, 23);
Label label_1 = new Label(container, SWT.NONE);
label_1.setAlignment(SWT.CENTER);
label_1.setBounds(232, 29, 43, 17);
label_1.setText("=");
Count = new Text(container, SWT.BORDER);
Count.setBounds(281, 23, 73, 23);
Button button = new Button(container, SWT.NONE);
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
}
});
button.setBounds(281, 78, 80, 27);
button.setText("\u8BA1\u7B97");
return container;
}
/**
* Create the actions.
*/
private void createActions() {
// Create the actions
}
/**
* Create the menu manager.
* @return the menu manager
*/
@Override
protected MenuManager createMenuManager() {
MenuManager menuManager = new MenuManager("menu");
return menuManager;
}
/**
* Create the toolbar manager.
* @return the toolbar manager
*/
@Override
protected ToolBarManager createToolBarManager(int style) {
ToolBarManager toolBarManager = new ToolBarManager(style);
return toolBarManager;
}
/**
* Create the status line manager.
* @return the status line manager
*/
@Override
protected StatusLineManager createStatusLineManager() {
StatusLineManager statusLineManager = new StatusLineManager();
return statusLineManager;
}
/**
* Launch the application.
* @param args
*/
public static void main(String args[]) {
try {
test window = new test();
window.setBlockOnOpen(true);
window.open();
Display.getCurrent().dispose();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Configure the shell.
* @param newShell
*/
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("New Application");
}
/**
* Return the initial size of the window.
*/
@Override
protected Point getInitialSize() {
return new Point(450, 300);
}
}