2011-10-12 3 views

답변

28

당신은 두 개의 인수 생성자를 사용하여 Shell 스타일의 비트를 지정할 수 있습니다 . 기본 스타일의 비트 SWT.SHELL_TRIM 다음과 같습니다

public static final int SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE; 

당신은 실제로 RESIZE 비트를 제외 할. 당신이 Shell 당신의 자신을 만드는 경우 :

final Shell shell = new Shell(parentShell, SWT.SHELL_TRIM & (~SWT.RESIZE)); 

당신이 Dialog를 확장하는 경우 getShellStyle을 overridding하여 쉘 스타일의 비트에 영향을 미칠 수있다 : [JFace의와 비 크기 조정 창]의

@Override 
protected int getShellStyle() 
{ 
    return super.getShellStyle() & (~SWT.RESIZE); 
} 
4

쉘을 선언 할 때 가구를 제어 할 수 있습니다. 나는이 예가 당신이 원하는 것을한다고 생각합니다.

import org.eclipse.swt.SWT; 
import org.eclipse.swt.graphics.Rectangle; 
import org.eclipse.swt.widgets.Display; 
import org.eclipse.swt.widgets.Event; 
import org.eclipse.swt.widgets.Listener; 
import org.eclipse.swt.widgets.Shell; 
import org.eclipse.swt.widgets.Text; 

public class FixedWindow { 
    public static void main(String[] args) { 
     Display display = new Display(); 

     //final Shell shell = new Shell(display); //defaults 
     //final Shell shell = new Shell(display, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX); //can be maximised 
     final Shell shell = new Shell(display, SWT.CLOSE | SWT.TITLE | SWT.MIN); // fixed but can be minimised 
     //final Shell shell = new Shell(display, SWT.TITLE); // fixed, uncloseable, unminimisable can only be removed by OS killing JVM. 

     Rectangle boundRect = new Rectangle(0, 0, 1024, 768); 
     shell.setBounds(boundRect); 
     Rectangle boundInternal = shell.getClientArea(); 

     shell.setText("Fixed size SWT Window."); 

     shell.open(); 

     final Text text = new Text(shell, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); 

     text.setEditable(true); 
     text.setEnabled(true); 
     text.setText("Oh help!"); 
     text.setBounds(boundInternal); 


     while (!shell.isDisposed()) { 

      if (!display.readAndDispatch()) 
       display.sleep(); 
     } 
     display.dispose(); 
    } 
} 
+0

고마워, 사실 나는 그동안 추가 : "새로운 쉘 (디스플레이, SWT.CLOSE | SWT.TITLE)" , 그리고 당신의 대답은 동일하지만 추가적으로 MIN을 가지고 있습니다 – alhcr

-1

나는 그것에 대해 잘 모르겠어요,하지만 난 그냥 같이 SWT.Resize 이벤트를 드롭 할 수 있다고 생각 :

shell.addListener (SWT.Resize, new Listener() { 
    public void handleEvent (Event e) 
    { 
     return; 
    } 
}); 
+2

이것은 실제로는 잘 작동하지 않습니다 - 리스너는 윈도우의 크기가 조정 된 후에 발생합니다. 따라서'e.doit'을 false로 설정해도 효과가 없습니다. 일부 플랫폼에서는 쉘 ** 백 **의 크기를 원래대로 설정하려고 시도 할 수 있지만 일부 플랫폼에서는 이상하게 보입니다 (특히 와이어 프레임 크기 조정 또는 해당 이벤트를 실행하기 전에 상당한 크기 조정이 가능한 플랫폼).) 다른 플랫폼에서는 크기를 변경하려는 플래그를 설정하지 않는 한 크기 조정 리스너 내부에서 셸 크기를 조정할 때 실제로 무한 루프의 이벤트가 발생합니다. –

관련 문제