0
왼쪽에는 스크롤 패널이 있고 오른쪽에는 사용 가능한 공간을 채우지 만 덮지는 않은 대화 상자를 배치하려고합니다. 버튼 바에 의해 내 예제에서 볼 수있는 문제는 합성물이 무한한 양의 공간을 가지고 있다고 생각하는 것 같아요. 그리고 이것이 어떻게 작동하는지 이해할 수 없습니다.JFace 대화 상자 레이아웃 문제 창 경계 바깥으로 그려진 위젯
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class FMLDialog extends Dialog
{
public FMLDialog(Shell parentShell)
{
super(parentShell);
}
@Override
protected void configureShell(Shell shell)
{
super.configureShell(shell);
shell.setSize(new Point(700,500));
shell.setText("FML");
}
@Override
public Control createDialogArea(final Composite comp)
{
Composite content = (Composite) super.createDialogArea(comp);
Composite parent = new Composite(content, SWT.NONE);
GridLayout gridLayout1 = new GridLayout(1, false);
gridLayout1.verticalSpacing=10;
GridLayout gridLayout2 = new GridLayout(2, false);
parent.setLayout(gridLayout2);
parent.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
final ScrolledComposite scroll = new ScrolledComposite(parent, SWT.V_SCROLL);
scroll.setExpandHorizontal(true);
scroll.setExpandVertical(true);
Composite optionsPanel = new Composite(scroll, SWT.BORDER);
optionsPanel.setSize(optionsPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
optionsPanel.setLayout(gridLayout1);
scroll.setContent(optionsPanel);
for (int i = 0; i < 200; i++) {
new Label(optionsPanel, SWT.NONE).setText("this is item " + i);
}
scroll.setSize(optionsPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
final Canvas c = new Canvas(parent, SWT.BORDER);
c.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
c.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
Point size = c.getSize();
e.gc.drawText("Width: " + size.x + "\nHeight: " + size.y, 5, 5);
e.gc.drawOval(2, 2, size.x - 4, size.y - 4);
}
});
return content;
}
public static void main(String[] args) {
Display d = new Display();
Shell s = new Shell();
FMLDialog fml = new FMLDialog(s);
fml.open();
}
}
내가 당신 바즈 – Link19
믿을 수 Link19 @ 항상 즐거움 도움이 알고 :
여기에 작동 코드의 수정 된 버전입니다! – Baz