posts - 5,  comments - 0,  trackbacks - 0
          import org.eclipse.swt.SWT;
          import org.eclipse.swt.events.SelectionAdapter;
          import org.eclipse.swt.events.SelectionEvent;
          import org.eclipse.swt.widgets.Button;
          import org.eclipse.swt.widgets.Combo;
          import org.eclipse.swt.widgets.Display;
          import org.eclipse.swt.widgets.Shell;


          public class ComboTest {

              private static Combo combo_2;
              private static Combo combo_1;
              private static Combo combo;
              /**
               * Launch the application
               * @param args
               */
              public static void main(String[] args) {
                  final Display display = Display.getDefault();
                  final Shell shell = new Shell();
                  shell.setSize(461, 337);
                  shell.setText("SWT Application");
                  //

                  shell.open();

                  combo = new Combo(shell, SWT.NONE);
                  combo.setBounds(123, 116, 141, 20);

                  final Button button = new Button(shell, SWT.NONE);
                  button.addSelectionListener(new SelectionAdapter() {
                      public void widgetSelected(SelectionEvent e) {
                          combo.removeAll();//先 清空
                          for (int i=1; i<=10;i++)
                              combo.add("第"+i+"字符串");//添加字符串
                              combo.select(0);//設置第一級為當前項
                      }
                  });
                  button.setText("設值");
                  button.setBounds(105, 189, 48, 22);

                  final Button button_1 = new Button(shell, SWT.NONE);
                  button_1.addSelectionListener(new SelectionAdapter() {
                      public void widgetSelected(SelectionEvent e) {
                          //MessageDialog.openInformation(shell,null,combo.getText());
                      }
                  });
                  button_1.setText("取值");
                  button_1.setBounds(231, 189, 48, 22);

                  combo_1 = new Combo(shell, SWT.READ_ONLY);//只讀
                  combo_1.setBounds(313, 52, 52, 20);

                  combo_2 = new Combo(shell, SWT.SIMPLE);//一直顯示
                  combo_2.setBounds(313, 164, 52, 20);
                  shell.layout();
                  while (!shell.isDisposed()) {
                      if (!display.readAndDispatch())
                          display.sleep();
                  }
              }

          }


          posted on 2008-03-31 07:09 hakuci 閱讀(290) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2008年3月>
          2425262728291
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          常用鏈接

          留言簿(1)

          隨筆檔案(5)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 永平县| 道孚县| 霍林郭勒市| 汾阳市| 宝鸡市| 咸宁市| 阿克苏市| 集贤县| 高州市| 正镶白旗| 洛宁县| 潢川县| 即墨市| 隆安县| 论坛| 霍城县| 民勤县| 大竹县| 南漳县| 庄河市| 伊吾县| 齐河县| 六安市| 酉阳| 昆明市| 柏乡县| 化州市| 东乡族自治县| 石河子市| 九江县| 高要市| 玛纳斯县| 鄂尔多斯市| 旬阳县| 靖州| 抚顺市| 乌审旗| 巴林左旗| 肇东市| 定兴县| 哈密市|