小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

第一個(gè)SWT程序

 印度阿三17 2019-12-19
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;


public class HelloSWT extends Shell{
    
    // 這些都是在下面將要用到的控件
    private static Text text;
    private static Button swtButton;
    private static Button awtButton;
    private static Button swingButton;
    private static Group group;
    private static Button button;
    private static Label benefitOfSwtLabel;
    private static List list;

    public static void main(String[] args) {

        /**
         * 創(chuàng)建一個(gè)Display對(duì)象,并使用這個(gè)Display創(chuàng)建一個(gè)
         * 窗口Shell,并設(shè)置它的標(biāo)題和窗口初始尺寸。因?yàn)楫?dāng)
         * 前線程創(chuàng)建了Display對(duì)象,所以它是界面線程
         */
        Display display = Display.getDefault();
        final Shell shell = new Shell(display);
        shell.setText("Hello SWT");
        shell.setSize(260, 283);
        
        shell.open();
        
        /**
         * 創(chuàng)建一個(gè)Text空間并設(shè)置其中文字的內(nèi)容。然后設(shè)置了
         * 空間在窗口中的位置
         * 左上頂點(diǎn)為(10,8),寬度為230,高度為35
         */
        text = new Text(shell, SWT.BORDER);
        text.setText("SWT是Eclipse平臺(tái)使用的圖形工具箱");
        text.setBounds(10, 8, 230, 35);
        
        /**
         * List控件可以用來(lái)展示一系列的內(nèi)容。這里創(chuàng)建了4條內(nèi)容
         * 的List控件
         */
        list = new List(shell, SWT.BORDER);
        list.setItems(new String[] {
            "使用操作系統(tǒng)本地控件",
            "提供一套平臺(tái)無(wú)關(guān)的API",
            "GUI程序的運(yùn)行速度快",
            "更多更多......"
        });
        
        /**
         * Label控件可以在界面上展示不能修改的文字,通常作為
         * 標(biāo)簽來(lái)使用
         */
        benefitOfSwtLabel = new Label(shell, SWT.NONE);
        benefitOfSwtLabel.setText("SWT的優(yōu)點(diǎn):");
        benefitOfSwtLabel.setBounds(10, 49, 90, 15);
        
        /**
         * Group對(duì)象可以用來(lái)把相關(guān)的控件組成一組,在這一組控件
         * 的外面會(huì)顯示出一個(gè)邊框,將它們和其他控件隔離開來(lái)。在邊框
         * 上可以加入文字標(biāo)題以說(shuō)明這一組控件的作用。
         */
        group = new Group(shell, SWT.NONE);
        group.setText("你使用過(guò)哪些圖形工具箱?");
        group.setBounds(10, 159, 230, 47);
        
        /**
         * Button類型包含普通按鈕,單選按鈕,復(fù)選按鈕等很多形式。
         * 
         */
        awtButton = new Button(group, SWT.CHECK);
        awtButton.setText("AWT");
        awtButton.setBounds(10, 20, 54, 18);
        
        swingButton = new Button(group, SWT.CHECK);
        swingButton.setText("Swing");
        swingButton.setBounds(70, 22, 60, 15);
        
        swtButton = new Button(group, SWT.CHECK);
        swtButton.setBounds(136, 22, 62, 15);
        swtButton.setText("SWT");
        
        button = new Button(shell, SWT.None);
        button.addSelectionListener(new SelectionListener() {
            
            @Override
            public void widgetSelected(SelectionEvent arg0) {
                MessageBox messageBox = 
                        new MessageBox(shell, SWT.ICON_INFORMATION);
                messageBox.setMessage("Hello SWT");
                messageBox.open();
            }
            
            @Override
            public void widgetDefaultSelected(SelectionEvent arg0) {
                // TODO Auto-generated method stub
                
            }
        });
        
        button.setText("按一下按鈕,向SWT說(shuō)Hello!");
        button.setBounds(10, 214, 227, 25);
        shell.layout();
        
        while(!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
    }
}
來(lái)源:https://www./content-1-599801.html

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多