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)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 赞皇县| 商水县| 遵化市| 兰溪市| 酉阳| 高密市| 江川县| 舞钢市| 海兴县| 洪雅县| 于田县| 道真| 秦皇岛市| 镇赉县| 繁昌县| 宁津县| 富民县| 蒲江县| 莒南县| 开平市| 潮安县| 湘潭县| 鄄城县| 松原市| 吉隆县| 平原县| 康平县| 峨眉山市| 阳谷县| 榆中县| 永定县| 托克逊县| 孝感市| 平陆县| 宜阳县| 梧州市| 武定县| 滦南县| 芮城县| 达拉特旗| 阳江市|