IT/RCP

[SWT] Layout

원창연 2020. 12. 19. 23:22

레이아웃에 대해서는 잘되어 있는 사이트 먼저 공유하고자 합니다.

(참고 : https://www.eclipse.org/articles/Article-Understanding-Layouts/Understanding-Layouts.htm) 구글에 SWT layout하면 가장 많이 검색되는 화면입니다

 

 

ㅁ MarginLeft, MarginTop, MarginRight, MarginButton Vertical/Horizontal Spacing

 

그리고 layout은 SWT, JFACE 모두 동일하게 사용되어 집니다. 위젯들을 어떻게 배치하고 화면이 늘려짐에 따라 어떤것들이 늘어나고 고정되는지에 대한 얘기 입니다.

 

1. FillLayout

    FillLayout fillLayout = new FillLayout()

    fillLayout.type        = SWT.VERTICAL

    shell.setLayout(fillLayout)    적용하려는 Composite, Shell 등등에 적용

 

 

2. RowLayout

    RowLayout rowLayout = new RowLayout();

    rowLayout.wrap = false;

    rowLayout.pack = false;

    rowLayout.justify = true;

    rowLayout.marginLeft = 5;

    rowLayout.marginTop = 5;

    rowLayout.marginRight = 5;

    rowLayout.marginBottom = 5;

    rowLayout.spacing = 0;

    shell.setLayout(rowLayout);

    wrap(기본 true) : false한행 유지, 부모가 가시적으로 줄어들 때 안보이는게 발생

    pack(기본 true) : false인경우 본래 size사용

    justify(기본 false) : true인경우 균등하게 배치

 

3. GridLayout

   가장많이 사용되어집니다.

4. GridData

  setLayoutData메소드 사용

  Button button1 = new Button(shell, SWT.PUSH);

  button1.setText("B1");

  button1.setLayoutData(new GridData());