Setting Component Alignment


When you snap a component to an edge of another component or the side of the a container, you also set the component's alignment. For example, in Figure 6-6, the JLabel is right-aligned to the edge of the JTextField. As you enter longer text, the JLabel expands to the left.

Figure 6-6. JLabel right-aligned to a JTextField's edge


In some cases, you have to manually adjust the alignment of components. Consider the form in Figure 6-7. The two labels were entered first, and their display text set. The text fields were then entered and snapped to the right edges of the labels.

Figure 6-7. Form before realigning the JLabels


We want to make the JLabels right-aligned so the two JTextFields line up along their left edges. To do so, shift-click the two JLabels to select them and click the button in the Form Designer toolbar. The result is shown in Figure 6-8.

Figure 6-8. Form after realigning the JLabels




NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net