第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

將文本包裹在 Button 內(nèi)

將文本包裹在 Button 內(nèi)

猛跑小豬 2022-05-21 20:49:24
我在嘗試做似乎很容易的事情時(shí)遇到了問(wèn)題。在 java/swt 中編碼 UI,我試圖在兩行上顯示按鈕的文本(包裝傳遞給按鈕的字符串),但我無(wú)法通過(guò)字符串中的回車(chē)來(lái)做到這一點(diǎn),也不使用按鈕的 SWT.WRAP 樣式。這是我的代碼示例:Button myButton = new Button(compoCentre, SWT.WRAP);myButton.setBounds(40, 200, 240, 40);myButton.setText("A long text, but not so long, just enough);但是,這會(huì)導(dǎo)致文本顯示在一行上,隱藏不適合按鈕大小的部分。有什么想法/解決方法嗎?感謝您的時(shí)間。
查看完整描述

1 回答

?
SMILET

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超4個(gè)贊

查看以下代碼:


public class Sample {

    public static void main(String[] args) {

        Display display = new Display();

        Shell shell = new Shell(display);

        shell.setLayout(new GridLayout(1, false));


        Composite comp = new Composite(shell, SWT.NONE);

        comp.setLayout(new GridLayout(1, false));

        comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));


        Button testButton = new Button(comp, SWT.PUSH | SWT.WRAP);

        testButton.setText("A long text, but not so long, just enough");

        final GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);

        layoutData.widthHint = 100;

        testButton.setLayoutData(layoutData);


        shell.pack();

        shell.open();

        while (!shell.isDisposed()) {

            if (!display.readAndDispatch()) {

                display.sleep();

            }

        }

        display.dispose();

    }

}

Windows 10 上的輸出:

http://img1.sycdn.imooc.com//6288dfee00019ee905610150.jpg

http://img1.sycdn.imooc.com//6288dff60001ea0701730140.jpg

查看完整回答
反對(duì) 回復(fù) 2022-05-21
  • 1 回答
  • 0 關(guān)注
  • 147 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)