2014-07-26 4 views
-1

이미지의 미리보기 이미지에 RowLayout을 사용하고 있습니다. 모든 축소 이미지가 한 행에만 표시됩니다. 크기를 조정할 때 여러 행에 효율적으로 표시되도록하려면 어떻게해야합니까?RowLayout의 내용을 줄 바꿈하는 방법?

+0

당신의 대답은 아주 좋습니다. 고맙습니다. 하지만 제 문제는 뭔가 다른 것이 었습니다. 랩과 관련이 없었습니다. – Baber

+0

그 답을 수락 하시겠습니까? – Baz

+0

답변이 도움이됩니다. 당신의 대답 때문에 RowLayout의 랩 기능을 알게되었습니다. – Baber

답변

1

RowLayout의 설명서에서 쉽게 찾을 수 있습니다.

은 당신이 찾고있는 RowLayout#wrap입니다 :

랩은 현재 행의 공간이 부족하면 컨트롤이 다음 행으로 포장할지 여부를 지정합니다. 기본값은 true입니다.

기본이 true, 이미 포장해야하기 때문에

...

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

    RowLayout layout = new RowLayout(); 
    layout.wrap = true; 
    shell.setLayout(layout); 

    Image image = new Image(display, "star.png"); 

    for(int i = 0; i < 10; i++) 
     new Label(shell, SWT.NONE).setImage(image); 

    shell.pack(); 
    shell.setSize(200, 100); 
    shell.open(); 

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

    image.dispose(); 
} 

은 크기를 조정하기 전에 다음과 같습니다

enter image description here

그리고 이후

크기 조정 :

enter image description here

관련 문제