I wanted to add one scrollbar into the RoundedRectangle. I have 3 Rounded rectangle in the root figure. Now I want to add scrollbar to each of the rounded rectangle. Is it possible to add the scrollbar to the rounded rectangle or rectangle figure? I used the following way . But it does not show any figure to me. How to make it work? In the below example, I have added only one rectangle.
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();
}
}