[Draw2D] Zoom with GridLayout help [message #677063] |
Tue, 07 June 2011 08:54 |
Eclipse User |
|
|
|
I'm trying to create a couple of composite figures each with 2 rows of labels. The first row has 3 labels with equal widths and the second row has a label that spans 3 columns.
I'm using GridLayout to layout my figures as BorderLayout and ToolbarLayout didn't work for me. However when I zoom in, spaces appear between my labels.
This is a snippet of my code, I've replaced the createContents() method in Draw2D's ZoomExample.
How can I remove the spaces between the labels?
private static Figure createContents() {
Figure contents = new Figure();
XYLayout layout = new XYLayout();
contents.setLayoutManager(layout);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
gridLayout.makeColumnsEqualWidth = true;
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
RectangleFigure rectFigure = new RectangleFigure();
rectFigure.setBounds(new Rectangle(30, 30, 100, 50));
rectFigure.setLayoutManager(gridLayout);
Label label1 = new Label("A");
label1.setBackgroundColor(ColorConstants.blue);
label1.setOpaque(true);
rectFigure.add(label1);
Label label2 = new Label("B");
label2.setBackgroundColor(ColorConstants.red);
label2.setOpaque(true);
label2.setOpaque(true);
rectFigure.add(label2);
Label label3 = new Label("C");
label3.setBackgroundColor(ColorConstants.green);
label3.setOpaque(true);
label3.setOpaque(true);
rectFigure.add(label3);
Label label4 = new Label("DEF");
label4.setBackgroundColor(ColorConstants.yellow);
label4.setOpaque(true);
label4.setOpaque(true);
rectFigure.add(label4);
GridData gridData = new GridData();
gridData.horizontalSpan = 3;
rectFigure.setConstraint(label4, gridData);
contents.add(rectFigure);
return contents;
}
|
|
|
Powered by
FUDForum. Page generated in 0.03374 seconds