2014-10-31 3 views
2

다른 컴포지트 (대화 상자 영역) 안에있는 컴포지트 (컨테이너)가 있습니다. 컨테이너에는 몇 가지 UI 요소가 포함되어 있습니다. 대화 상자의 크기를 더 크게 만들거나 크기를 조정할 수있는 방법은 무엇입니까? 당신이에 폭 또는 높이 힌트를 설정할 수 있습니다 열 때자바에서 Resizeble 대화 SWT

@Override 
protected boolean isResizable() { 
    return true; 
} 

대화를 크게하려면 여기 isResizable 방법에 대한 재정의를 추가 JFace는 대화 상자가 크기를 조정할 수 있도록하려면

protected Control createDialogArea(Composite parent) { 
    setMessage("Enter user information and press OK"); 
    setTitle("User Information"); 
    Composite area = (Composite) super.createDialogArea(parent); 
    Composite container = new Composite(area, SWT.NONE); 
    container.setLayout(new GridLayout(2, false)); 
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); 

    Label lblUserName = new Label(container, SWT.NONE); 
    lblUserName.setText("User name"); 

    txtUsername = new Text(container, SWT.BORDER); 
    txtUsername.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); 
    txtUsername.setEditable(newUser); 
    txtUsername.setText(name); 

    return area; 
} 

답변

7

내 코드입니다 형세.

@Override 
protected Point getInitialSize() { 
    final Point size = super.getInitialSize(); 

    size.x = convertWidthInCharsToPixels(75); 

    size.y += convertHeightInCharsToPixels(20); 

    return size; 
} 
:

GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1); 
data.widthHint = convertWidthInCharsToPixels(75); 
txtUsername.setLayoutData(data); 

또는이 코드가 수직 이상의 문자 수평 (75 자) 및 (20 개 라인)을위한 공간을 떠나, 예를 들어 getInitialSize()을 재정의 할 수 있습니다 : 예를 들어,

관련 문제