Placing a background under the pins

To make the grid look like a package a background is placed under the grid of pins and a white background is used in the applet so the background is discernible.

01:	public class TutorialExample5 extends Applet {
02:
03:		public void init () {
04:		setBackground(Color.white);
05:
06:		FigureStyle style = new FigureStyle();
07:		style.foreground = Color.yellow;
08:		style.brushSize = 1;
09:
10:		Glyph verticalBox = LayoutKit.vbox();
11:
12:		for (int row = 0; row < 8; row++) {
13:			Glyph horizontalRow = LayoutKit.hbox();
14:			for (int col = 0; col < 8; col++)
15:				if (row > 1 && row < 6 && col > 1 && col < 6) {
16:					horizontalRow.append(LayoutKit.hspace(32));
17:				}
18:				else {
19:					horizontalRow.append(
20:						LayoutKit.margin(
21:							new Pin("FakeName", 20F),
22:							6
23:						)
24:					);
25:				}
26:			verticalBox.append(horizontalRow);
27:		}
28:
29:		Glyph device = LayoutKit.margin(new Background(verticalBox, Color.gray, true, true), 20);
30:
31:		SgraphicsAdapter adapter = new SgraphicsAdapter(device);
32:
33:		add("Center", adapter);
34:		}
35:	}

The background color of the applet is set to white on line 4 to ensure that the background is not hidden by the browsers background. The background is wrapped around the vertical box in line 29. The color is set to gray, and is 3 dimensional.


Beginning of example
Previous
Next

For comments or questions contact Mike Jones (Mike.Jones@mass.com)