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

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

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

    posts - 4,  comments - 7,  trackbacks - 0

        工作中一個(gè)任務(wù)是為一個(gè)已經(jīng)有的Composite添加滾動(dòng)條,原以為可以這樣實(shí)現(xiàn):
        Composite scrollabledComposite = new Composite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
         再設(shè)置一下其它的參數(shù)就可以了,誰(shuí)知這樣是可以添加滾動(dòng)條,但是滾動(dòng)條里的Composite根本不會(huì)跟著動(dòng);于是,查API,發(fā)現(xiàn)有ScrolledComposite這個(gè)類,好家伙,這個(gè)類里的注釋連main () 方法都提供了,正點(diǎn)!

    于是,我的代碼如下:

           parentComposite.setLayout(new FillLayout());
            ScrolledComposite scrolledComposite = new ScrolledComposite(parentComposite,  SWT.H_SCROLL|SWT.V_SCROLL);
           
            Composite mainComposite = new Composite(scrolledComposite,SWT.NONE);
            scrolledComposite.setContent(mainComposite);
            mainComposite.setBackground(Display.getCurrent().getSystemColor (SWT.COLOR_WHITE));// White color
            mainComposite.setLayout(new GridLayout(1,true));
            GridData data = new GridData(GridData.FILL_BOTH);
            mainComposite.setLayoutData(data);
          

            Composite topComposite = new Composite(mainComposite, SWT.BORDER);
            topComposite.setLayout(new GridLayout(2, false));
            topComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));// White color

            reloadBtn = new Button(topComposite, SWT.PUSH);
            reloadBtn.setText("&Reload from preferences");
            reloadBtn.setToolTipText("Reload values from preference page(Shift+R)");

            saveBtn = new Button(topComposite, SWT.PUSH);
            saveBtn.setText("&Save to preferences");
            saveBtn.setToolTipText("save values to preference page(Shift+S)");
           
            scrolledComposite.setExpandHorizontal(true);
            scrolledComposite.setExpandVertical(true);
            scrolledComposite.setMinWidth(800);
            scrolledComposite.setMinHeight(400);


     總結(jié):
     1)在為Composite添加滾動(dòng)條時(shí),最上面的Composite的布局需設(shè)為FillLayout();
     2) 不要直接往scrolledComposite上面添加控件;
     3) 在創(chuàng)建完ScrolledComposite后不要忘記使用setContent()方法去設(shè)置滾動(dòng)條所控制的Composite;
     4) 最重要的是,Scrolledcomposite的以下四個(gè)參數(shù)必須設(shè)置才能出現(xiàn)滾動(dòng)條:
        scrolledComposite.setExpandHorizontal(true);
        scrolledComposite.setExpandVertical(true);
        scrolledComposite.setMinWidth(800);
        scrolledComposite.setMinHeight(400);
        只有前兩項(xiàng)設(shè)為true之后,后面的兩項(xiàng)才起作用。
    5) 對(duì)于setMinWidth()和setMinHeight()方法,API的注釋中是說(shuō)用來(lái)設(shè)置滾動(dòng)條出現(xiàn)的最小寬度和高度,但是我試了一下,有時(shí)出現(xiàn)滾動(dòng)條了,
        但是拖動(dòng)滾動(dòng)條還是不能顯示Composite里面的全部?jī)?nèi)容,于是把setMinWidth()和setMinHeight()設(shè)大一些就可以了,個(gè)人感覺滾動(dòng)條出現(xiàn)的
        寬度和高度檢測(cè)Scrolledcomposite自己已經(jīng)實(shí)現(xiàn)了,這里的寬度和高度是指拖動(dòng)滾動(dòng)條里可以看到的Composite的最大寬度和最大高度。

     

    posted on 2007-10-30 09:20 jackgogogo(Dengues Studio) 閱讀(4805) 評(píng)論(4)  編輯  收藏

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲国产成人久久精品99| 久久国产乱子免费精品| 久久精品无码一区二区三区免费| 18gay台湾男同亚洲男同| 伊人久久免费视频| 亚洲成av人片不卡无码| 日韩亚洲国产高清免费视频| 亚洲国产综合自在线另类| 免费福利视频导航| 亚洲精品123区在线观看| 日本19禁啪啪无遮挡免费动图| 亚洲欧美国产精品专区久久| 国产精品嫩草影院免费| 九九视频高清视频免费观看 | 午夜宅男在线永久免费观看网| 亚洲精品在线播放| 日韩av无码成人无码免费 | 精品特级一级毛片免费观看| 亚洲精品国产精品乱码不卞| 国产成人高清精品免费观看| 亚洲精品成人无码中文毛片不卡| 一级毛片免费观看不卡的| 亚洲日本视频在线观看| 精品免费国产一区二区三区 | 狠狠久久永久免费观看| 日本中文字幕免费看| 久久精品国产精品亚洲色婷婷| 99久久99这里只有免费费精品| 亚洲av永久中文无码精品| 亚洲综合av永久无码精品一区二区| 日本免费人成视频在线观看| 2020亚洲男人天堂精品| 亚洲中久无码不卡永久在线观看| 国产精品免费AV片在线观看| 中文字幕亚洲码在线| 国产偷国产偷亚洲清高动态图| 99久久免费精品视频| 西西人体大胆免费视频| 久久精品a亚洲国产v高清不卡 | 国产成人无码区免费内射一片色欲 | 亚洲精品国产品国语在线|