2016-07-06 8 views

答えて

2

それが可能だ確か:

public static void main(String[] args) { 
    final Display display = new Display(); 
    final Shell shell = new Shell(display); 
    shell.setText("Stackoverflow"); 
    shell.setLayout(new FillLayout()); 

    ScrolledComposite sc = new ScrolledComposite(shell, SWT.V_SCROLL | SWT.H_SCROLL); 

    Button button = new Button(sc, SWT.NONE); 
    button.setText("Hello! This is a button with a lot of text..."); 

    sc.setContent(button); 
    sc.setExpandHorizontal(true); 
    sc.setExpandVertical(true); 
    sc.setMinSize(button.computeSize(SWT.DEFAULT, SWT.DEFAULT)); 

    shell.pack(); 
    shell.open(); 

    while (!shell.isDisposed()) 
    { 
     if (!display.readAndDispatch()) 
      display.sleep(); 
    } 
    display.dispose(); 
} 

リサイズする前に:

enter image description here

のサイズを変更した後:

enter image description here

だけでScrolledComposite#setContent(Control)を呼び出すことを覚えていますをパラメータとして使用します。

+0

yup。私は#setcontentを忘れてしまった。ありがとう。 – Rajasekhar

関連する問題