<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    DANCE WITH JAVA

    開發出高質量的系統

    常用鏈接

    統計

    積分與排名

    好友之家

    最新評論

    swt入門 --常用組件的使用

    swt的常用組件button ,text ,combo,list ,還有一些容器類composite ,group,這里選擇幾個,列寫簡單的用法
    不寫解釋了,因為代碼很簡單,而且代碼上的注釋足以說明.
    1,combo  和text
    package com.test;

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.widgets.Combo;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.List;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;

    public class CTShow {

        
    private static List list;
        
    private static Combo combo;
        
    private static Text text;
        
    public static void main(String[] args) {
            
    final Display display = Display.getDefault();
            
    final Shell shell = new Shell();
            shell.setSize(
    478120);
            shell.setText(
    "combo and text");
            shell.open();
            
    //構造text
            text = new Text(shell, SWT.BORDER);
            text.setBounds(
    1603428120);
            
    //構造combo
            combo = new Combo(shell, SWT.NONE);
            combo.setItems(
    new String[] {"one""two""three""four"});
            combo.setData(
    "one""1");
            combo.setData(
    "two""2");
            combo.setData(
    "three""3");
            combo.setData(
    "four""4");
            combo.setBounds(
    283410220);
            
    //添加監聽器
            combo.addSelectionListener(new SelectionAdapter(){
                
    public void widgetSelected(SelectionEvent e){
                    String selText 
    = combo.getText();
                    String selValue 
    = (String)combo.getData(selText);
                    text.setText(
    "text: " + selText + " value: " + selValue);
                }
    }
    );
            
            shell.layout();
            
    //消息循環
            while (!shell.isDisposed()) {
                
    if (!display.readAndDispatch())
                    display.sleep();
            }

        }


    }

    2,list、 button 、messagebox
    package com.test;

    import org.eclipse.jface.dialogs.MessageDialog;
    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.Display;
    import org.eclipse.swt.widgets.List;
    import org.eclipse.swt.widgets.Shell;

    public class LBMShow {

        
    private static List list;
        
    /**
         * Launch the application
         * 
    @param args
         
    */

        
    public static void main(String[] args) {
            
    final Display display = Display.getDefault();
            
    final Shell shell = new Shell();
            shell.setSize(
    192217);
            shell.setText(
    "list and button and messagebox");
            
    //

            shell.open();
            
    //構造list
            list = new List(shell, SWT.BORDER|SWT.MULTI|SWT.V_SCROLL);
            list.setItems(
    new String[] {"語文""數學""英語""物理""化學"});
            list.setData(
    "化學""HX");
            list.setData(
    "物理""WL");
            list.setData(
    "語文""YW");
            list.setData(
    "數學""SX");
            list.setData(
    "英語""YY");
            list.setBounds(
    292510075);
            
    //構造button
            final Button button = new Button(shell, SWT.NONE);
            button.setText(
    "提示");
            button.setBounds(
    481215822);
            
    //添加監聽器
            button.addSelectionListener(new SelectionAdapter(){
                
    public void widgetSelected(SelectionEvent e){
                    
    for (String str : list.getSelection()) {
                        
    //messagebox提示
                        MessageDialog.openInformation(nullnull, str);
                    }

                }

            }
    );
            
            shell.layout();
            
    //消息循環
            while (!shell.isDisposed()) {
                
    if (!display.readAndDispatch())
                    display.sleep();
            }

        }


    }

    3,group組
    package com.test;

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Group;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;

    public class GroupShow {
        
    private static Text text;
        
    public static void main(String[] args) {
            
    final Display display = Display.getDefault();
            Shell shell 
    = new Shell();
            shell.setText(
    "group");
            shell.open();
            
    //構造group
            final Group group = new Group(shell, SWT.NONE);
            group.setText(
    "   組  ");
            group.setBounds(
    4128143100);
            
    //把按鈕放在group中,注意new Button(group這里
            final Button button = new Button(group, SWT.NONE);
            button.setText(
    "按鈕");
            button.setBounds(
    42594822);
            
    //構造text
            text = new Text(group, SWT.BORDER);
            text.setBounds(
    32288025);
            
    //
            shell.layout();
            
    while(!shell.isDisposed()){
                
    if (!display.readAndDispatch()){
                    display.sleep();
                }

            }

        }

    }

    posted on 2007-08-02 17:53 dreamstone 閱讀(3422) 評論(0)  編輯  收藏 所屬分類: SWT和插件開發

    主站蜘蛛池模板: 又粗又黄又猛又爽大片免费| 亚洲精品视频免费在线观看| 亚洲熟妇少妇任你躁在线观看| 亚洲视频在线观看免费| 亚洲国产精品线在线观看| 男女作爱在线播放免费网站| 久久91亚洲精品中文字幕| 亚洲a一级免费视频| 亚洲福利秒拍一区二区| 国产一卡2卡3卡4卡2021免费观看| 亚洲一卡2卡4卡5卡6卡残暴在线| 在线观看免费高清视频| 亚洲AV色无码乱码在线观看| 一本色道久久88综合亚洲精品高清| 青草青草视频2免费观看| 亚洲中文字幕在线乱码| 久久永久免费人妻精品| 亚洲综合激情六月婷婷在线观看| 波多野结衣在线免费观看| 亚洲精品蜜夜内射| 国产亚洲成归v人片在线观看| 中文字幕久精品免费视频| 亚洲的天堂av无码| 日韩精品免费一区二区三区| 无码毛片一区二区三区视频免费播放 | 最近免费中文字幕4| 亚洲aⅴ无码专区在线观看| 国产日产亚洲系列最新| 久久99热精品免费观看动漫| 精品亚洲成A人无码成A在线观看 | 亚洲一区二区三区香蕉| 久久午夜夜伦鲁鲁片免费无码影视| 亚洲AV色吊丝无码| 亚洲女同成人AⅤ人片在线观看| 久久免费视频精品| 亚洲а∨精品天堂在线| 国产av天堂亚洲国产av天堂 | 亚洲无码视频在线| www视频免费看| 一本岛v免费不卡一二三区| 久久久久久亚洲精品成人|