<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 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    SWT Basic Controls -- Text

    Posted on 2006-03-13 16:30 fortune 閱讀(1089) 評論(1)  編輯  收藏 所屬分類: 我的學習筆記
    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 自動換行

    SWT.LEFT

    Left-align the contents of the control    左對齊

    SWT.CENTER

    Center-align the contents of the control  中間對齊

    SWT.RIGHT

    Right-align the contents of the control   右對齊



    Text Events

    Event

         Description

    SWT.DefaultSelection

         Default selection occurred (user pressed <Enter>)

    SWT.Modify

         Text has changed in the control  控件中的文本內容發生了改變

    SWT.Verify

         Text is to be validated in the control  文本內容需要驗證


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

    一共有2種類型的text控件:單行的和多行的


    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  (通過設置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的文本內容從start到end
    getCharCount()  返回字符的數目


    Passwords and the Echo Character

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

    Text text = new Text(parent, style);

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

    注意在不同的平臺上echo字符是不同的,我們常見的密碼echo字符是“*”,可以自己設置echo字符

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

    getEchoChar() 返回setEchoChar函數設置的echo,如果未設置則返回'\0',如果使用了SWT.PASSWORD 則返回的字符不確定
    通常來說自己設置echo字符是不明智的,因為這是平臺look and feel的一部分。


     Lines and Line Height

    getLineCount() 返回行數
    getLineHeight() 返回每行高度(像素)該值與字符的高度并不相同,因為行間有空隙

    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
    行定義符號










    評論

    # re: SWT Basic Controls -- Text  回復  更多評論   

    2006-03-15 13:16 by 余靈
    恩``寫的太好了我草!
    主站蜘蛛池模板: 亚洲人成在线免费观看| 免费无码一区二区| 一级特黄aa毛片免费观看| 亚洲av日韩精品久久久久久a| 日韩中文字幕免费视频| 亚洲国产精品无码久久一区二区| 国产一区二区三区免费观在线| 国产L精品国产亚洲区久久 | 国产精品无码一二区免费| 亚洲精品福利网泷泽萝拉| 18勿入网站免费永久| 97se亚洲国产综合自在线| 在线免费不卡视频| 亚洲av无码一区二区三区乱子伦 | 成全在线观看免费观看大全| 亚洲精品午夜无码专区| 中文字幕在线日亚洲9| 天天干在线免费视频| 色天使色婷婷在线影院亚洲| 国产男女爽爽爽爽爽免费视频| 亚洲国产日韩在线成人蜜芽 | 精品熟女少妇a∨免费久久| 亚洲视频国产视频| 无码中文字幕av免费放| 亚洲国产成人AV网站| 国产亚洲精品自在线观看| 少妇无码一区二区三区免费| 亚洲人成影院77777| 手机看片久久国产免费| 最近免费中文字幕中文高清| 亚洲黄色网址在线观看| 国产在线国偷精品产拍免费| 高潮毛片无遮挡高清免费 | 4338×亚洲全国最大色成网站| 久久久久国色av免费看| tom影院亚洲国产一区二区| 免费v片在线观看无遮挡| 99视频在线看观免费| 色欲色欲天天天www亚洲伊| 亚洲色无码专区在线观看| AV无码免费永久在线观看|