Part 4. Manipulating the Appearance of User Interface Controls

In your program's current interface, the UI controls may be sized, aligned and distributed unevenly, because you dropped them into the canvas by hand, and the push buttons were sized according to their text content rather than a common width.

In this section, you will use some of the Composition Editor's toolbar buttons to make the following changes:

Resize the UserList List Box

The list box for user names is not currently large enough to display any names. We will make it wider and deeper so that you can view available user names later. There are two ways you can resize any object:

Select the UserList list box and click on the handle on the bottom right corner. Drag it down until it fills most of the left side of the canvas. You can drag other corners if you like, until you are satisfied with the shape and size of  the list box.

Align the Main Push Buttons

You can align several objects so that the left, right, top, or bottom edges of all the objects are aligned. The last selected object stays put, and the others are aligned to it. Before you align the four push buttons, drag the last one (<< Save) until it is positioned just to the right of the list box. Do not worry about its vertical placement yet.

Select the first object by clicking mouse button 1. You can use the Ctrl key and the mouse to select several objects at once. Select the first four push buttons, ending with the <<Save button.

Click the Align Left button from the toolbar. This aligns the left edges of the selected objects to match the left edge of the last selected object, <<Save. Do not deselect the buttons yet. You will need to have them all selected in the same order for the next step.

Resize Push Button Widths

Since these four push buttons are all fairly close in width, it would be nice if they were all exactly the same width.

Click the Match Width button while the objects are still selected. This makes the other three buttons the same width as << Save. Like aligning, size-matching actions use the last selected object as the reference point, or anchor. Do not deselect the buttons yet.

Distribute Push Buttons

The push buttons might look better if the spaces between them were equal. They are already selected in top-to-bottom order; click the Distribute Vertically button to make the spaces between them the same. If you changed the selection order when resizing the button widths, the vertical order of the buttons would change to match the order in which you selected them.

The distribution made the gaps between the push buttons equal, but the gaps between them may be a bit wide. This is because distribution spaces the selected objects evenly across the entire height of the canvas (or its width, when you distribute horizontally). You can decrease this vertical spacing by selecting the Exit button as well as the others, and distributing vertically again. Notice that when you redistribute the buttons vertically, their horizontal placement does not change.

Distribute the Right-hand Section of the Canvas

Next, you can distribute the GUI elements on the right-hand side of the canvas. Starting at the top of the canvas (with UserName), select the three static text fields, the two entry fields, the spin button field, and the Exit push button. Then click the Distribute Vertically button.

Now, align the left edges of all these items except the Exit push button. Deselect that push button by holding down Ctrl and clicking mouse button 1 on it. Click Align Left .

Resize Entry Fields and Spin Button

These controls may run off the right edge of the screen. To resize them, select only one of them, for example the top one, drag its top right corner to the left until it fits within the canvas. Then, select all three controls, ending with the one you just resized, and click the Match Width button.

Align Exit Button with the Other Fields on the Right

Finally, align the right edge of the Exit button to the right edge of another right-hand entry field. Select the Exit button, then the entry field, then click Align Right .

Your user interface should now look something like the following:

You can now proceed to Part 5. Making Simple Connections, in which you will implement some of the connections that will determine the behavior of the user interface.