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);
}
}
...全文
216 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
浮云若水 2012-02-07
  • 打赏
  • 举报
回复
偶滴个神 我吧单词写错了 我还说 怎么点不出 gettext()来
浮云若水 2012-02-07
  • 打赏
  • 举报
回复
要在button 的事件监听里得到 numb1 和numb2 两个文本框的值 怎么得到?
浮云若水 2012-02-07
  • 打赏
  • 举报
回复
和Swing里面的不一样 纠结了

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧