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

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

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

    FORTUNE

    THE WAY TO THE MASTER...
    posts - 49, comments - 18, trackbacks - 0, articles - 1
      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    SWT Basic Controls -- Text

    Posted on 2006-03-13 16:30 fortune 閱讀(1098) 評(píng)論(1)  編輯  收藏 所屬分類(lèi): 我的學(xué)習(xí)筆記
    Text Hierarchy


    graphics/07inf07.gif

    Text Styles

    Style

    Description

    SWT.SINGLE

    Allow a single line to be edited  單行

    SWT.MULTI

    Allow multiple lines to be edited  多行

    SWT.READ_ONLY

    Make the control noneditable     不可編輯

    SWT.WRAP

    Allow strings to wrap instead of scrolling 自動(dòng)換行

    SWT.LEFT

    Left-align the contents of the control    左對(duì)齊

    SWT.CENTER

    Center-align the contents of the control  中間對(duì)齊

    SWT.RIGHT

    Right-align the contents of the control   右對(duì)齊



    Text Events

    Event

         Description

    SWT.DefaultSelection

         Default selection occurred (user pressed <Enter>)

    SWT.Modify

         Text has changed in the control  控件中的文本內(nèi)容發(fā)生了改變

    SWT.Verify

         Text is to be validated in the control  文本內(nèi)容需要驗(yàn)證


    text控件支持"plain"text,這意味著text中的字符必須都是同樣的字體和顏色,如果需要 更多的功能就使用org.eclipse.swt.custom.StyledText(eclipse為用戶(hù)定制的)注意StyledText不是本地(native)控件

    一共有2種類(lèi)型的text控件:?jiǎn)涡械暮投嘈械?BR>

    Single-Line and Multiline Text Controls

    SWT.SINGLE

    Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
    text.setText("Texan");


     SWT.MULTI
    與單行的text不同它可以含有scroll bar  (通過(guò)設(shè)置SWT.H_SCROLL or SWT.V_SCROLL )

    int style =
        SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
    Text text = new Text(parent, style);


    String Operations

    setText(String string)

    getText()

    getText(int start, int end)  獲取text的文本內(nèi)容從start到end
    getCharCount()  返回字符的數(shù)目


    Passwords and the Echo Character

    int style = SWT.SINGLE | SWT.BORDER | SWT.PASSWORD;

    Text text = new Text(parent, style);

    text.setText("fred54"); //在text上不會(huì)顯示"fred54",而是以echo字符代替

    注意在不同的平臺(tái)上echo字符是不同的,我們常見(jiàn)的密碼echo字符是“*”,可以自己設(shè)置echo字符

    setEchoChar(char echo)如果設(shè)置的字符是'\0'則不再隱藏字符,當(dāng)前的字符被顯示

    getEchoChar() 返回setEchoChar函數(shù)設(shè)置的echo,如果未設(shè)置則返回'\0',如果使用了SWT.PASSWORD 則返回的字符不確定
    通常來(lái)說(shuō)自己設(shè)置echo字符是不明智的,因?yàn)檫@是平臺(tái)look and feel的一部分。


     Lines and Line Height

    getLineCount() 返回行數(shù)
    getLineHeight() 返回每行高度(像素)該值與字符的高度并不相同,因?yàn)樾虚g有空隙

    public static void main(String[] args) {

        Display display = new Display();

        Shell shell = new Shell(display);

        Text text = new Text(shell, SWT.H_SCROLL|SWT.V_SCROLL);

        int rows = 5, columns = 10;

        GC gc = new GC(text);

        FontMetrics fm = gc.getFontMetrics();

        gc.dispose();

        int height = rows * text.getLineHeight();

        int width = columns * fm.getAverageCharWidth();

        text.setSize(text.computeSize (width, height));

        shell.pack();

        shell.open();

        while (!shell.isDisposed()) {

            if (!display.readAndDispatch()) display.sleep();

        }

        display.dispose();

      }


     Line Delimiters
    行定義符號(hào)










    評(píng)論

    # re: SWT Basic Controls -- Text  回復(fù)  更多評(píng)論   

    2006-03-15 13:16 by 余靈
    恩``寫(xiě)的太好了我草!
    主站蜘蛛池模板: 亚洲中文字幕无码久久综合网| 在线观看免费亚洲| 青柠影视在线观看免费高清| 久久久久亚洲爆乳少妇无 | 免费激情网站国产高清第一页 | 在线精品自拍亚洲第一区| 韩国免费三片在线视频| 亚洲爆乳无码精品AAA片蜜桃| 毛片a级三毛片免费播放| 亚洲一区二区观看播放| 国产精品无码一区二区三区免费| 亚洲精品色播一区二区| 免费一级做a爰片久久毛片潮喷| 午夜在线免费视频 | 免费黄网站在线看| 91亚洲va在线天线va天堂va国产| 亚洲美女视频免费| 亚洲欧洲无卡二区视頻| 亚洲国产日韩成人综合天堂| a级黄色毛片免费播放视频| 老司机亚洲精品影院无码| 蜜桃视频在线观看免费网址入口| 亚洲国产欧美国产综合一区 | 亚洲精品高清一二区久久| 999zyz**站免费毛片| 亚洲精品国产手机| 成人免费的性色视频| 亚洲国产精品无码久久久秋霞1| 久久综合九九亚洲一区| 中文字幕一精品亚洲无线一区| 亚洲色偷偷色噜噜狠狠99网| va亚洲va日韩不卡在线观看| a级毛片黄免费a级毛片| 亚洲成a人不卡在线观看| 啦啦啦www免费视频| 国产又黄又爽胸又大免费视频 | 亚洲色精品VR一区区三区| 亚洲av成人一区二区三区在线观看| 免费国产99久久久香蕉| 国产成人精品日本亚洲11| 亚洲国产成人a精品不卡在线|