1
하나의 스크롤바를 RoundedRectangle에 추가하고 싶습니다. 나는 루트 그림에서 3 둥근 사각형을가집니다. 이제 각 둥근 사각형에 스크롤바를 추가하고 싶습니다. 둥근 사각형 또는 사각형 그림에 스크롤 막대를 추가 할 수 있습니까? 나는 다음과 같은 방법으로 사용했다. 그러나 그것은 나에게 어떠한 수치도 보여주지 않습니다. 어떻게 작동 시키는가? 아래의 예에서는 하나의 직사각형 만 추가했습니다.그림에 scrollpane
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.LightweightSystem;
import org.eclipse.draw2d.RoundedRectangle;
import org.eclipse.draw2d.ScrollPane;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class RoundedRectangleTest {
public static void main(String args[]) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("Scrollpane Example");
// Create a root figure and simple layout to contain all other figures
Figure root = new Figure();
root.setFont(shell.getFont());
root.setLayoutManager(new XYLayout());
ScrollPane scrollPane = new ScrollPane();
RoundedRectangle r = new RoundedRectangle();
r.setBackgroundColor(ColorConstants.yellow);
Rectangle rect = new Rectangle(10, 10, 50, 50);
r.setBounds(rect);
scrollPane.setContents(r);
root.add(scrollPane);
FigureCanvas canvas = new FigureCanvas(shell, SWT.DOUBLE_BUFFERED);
canvas.setBackground(ColorConstants.white);
//canvas.setContents(scrollPane);
LightweightSystem lws = new LightweightSystem(canvas);
lws.setContents(root);
shell.setSize(400, 350);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
확인. 고마워요! – user414967