隨筆-9  評論-2  文章-0  trackbacks-0
            2011年6月29日
          import org.eclipse.swt.SWT;
          import org.eclipse.swt.events.SelectionAdapter;
          import org.eclipse.swt.events.SelectionEvent;
          import org.eclipse.swt.layout.GridLayout;
          import org.eclipse.swt.widgets.Combo;
          import org.eclipse.swt.widgets.Display;
          import org.eclipse.swt.widgets.Shell;

          public class ComboTest {

              
          public static void main(String[] args) {
                  String[] WEEK 
          = { "Monday""Tuesday""Wednesday"};
                  Display display 
          = new Display();
                  Shell shell 
          = new Shell(display);
                  shell.setBounds(
          500100500300);
                  shell.setText(
          "Combo");
                  shell.setLayout(
          new GridLayout(3true));
                  
                  
          //創建Combo組件,為下拉列表樣式
                  final Combo dc = new Combo(shell, SWT.DROP_DOWN);
                  dc.setItems(WEEK);
                  dc.addSelectionListener(
          new SelectionAdapter(){
                      @Override
                      
          public void widgetSelected(SelectionEvent e) {
                          String key 
          = ""+dc.getSelectionIndex();
                          String value 
          = dc.getText();
                          System.out.println(
          "key:"+key+"    value:"+value);
                      }
                  });
                  
                  
          //創建Combo組件,為下拉列表樣式,且只讀
                  final Combo rc = new Combo(shell, SWT.DROP_DOWN | SWT.READ_ONLY);
                  
          //在界面中顯示的是123
                  rc.add("123");
                  
          //第一個值是key從0開始 ,第二個值為value
                  rc.setData("0""321");
                  
                  rc.add(
          "456");
                  rc.setData(
          "1""654");
                  
                  rc.addSelectionListener(
          new SelectionAdapter(){
                      @Override
                      
          public void widgetSelected(SelectionEvent e) {
                          String key 
          = ""+rc.getSelectionIndex();
                          System.out.println(
          "key:"+key);
                          String value 
          = (String) rc.getData(key);
                          System.out.println(
          "key:"+key+"    value:"+value);
                      }
                  });
                  
          //rc.setItems(MONTHS);
                  
          //創建Combo組件,為List組件樣式
                  Combo sc = new Combo(shell, SWT.SIMPLE);
                  sc.setItems(WEEK);
                  shell.open();
                  
          while (!shell.isDisposed()) {
                     
          if (!display.readAndDispatch()) {
                         display.sleep();
                    }
               }

               display.dispose();

              }

          }
          posted @ 2011-08-02 14:22 secret_x15 閱讀(12896) | 評論 (0)編輯 收藏
           Eclipse添加DTD文件實現xml的自動提示功能

          1.點擊 window -->Preferences -->XML -->XML Catalog  -->Add..

          2.點擊Add 彈出一個對話框,如圖所示



          3.填寫文本框中的內容

          Location : dtd的路徑。可以是eclipse工作空間的dtd,也可以是文件中的dtd。
          Key type:選擇 Public ID
          Key:為ibatis xml文件頭中<!DOCTYPE sqlMapConfig PUBLIC 后面的一段。即:-//ibatis.apache.org//DTD SQL Map Config 2.0//EN

          4. 點擊OK 按鈕,重啟eclipse.
          posted @ 2011-06-29 18:18 secret_x15 閱讀(5458) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 磐安县| 永春县| 泰安市| 蕉岭县| 沙田区| 武汉市| 望城县| 宜丰县| 屏山县| 鄱阳县| 阿城市| 昌江| 昌都县| 宜丰县| 阿鲁科尔沁旗| 宾阳县| 凌海市| 东海县| 阿图什市| 沈丘县| 五常市| 兴宁市| 金塔县| 乌拉特中旗| 盈江县| 苗栗市| 开阳县| 边坝县| 康马县| 屏东市| 台北县| 沾益县| 林芝县| 文山县| 万山特区| 虞城县| 五大连池市| 镶黄旗| 玛曲县| 临清市| 乌兰浩特市|