Tutorial Step 5 Step 7

Creating a UI with nested layouts

Step 6: Adding a label and a text area

Now let's work on the center panel, panel 3, which will contain a labeled command line and a text editing area.

First add the label and the text field for the command line:

  1. Click the top, left corner of panel 3 and add a shallow panel (panel 12), drawing it completely across the top. Change the panel to XYLayout or null.

  2. Add a short Swing JLabel (Label 1) to the left end of panel 12.

  3. Select Label1 and change the following property values in the Inspector:

  4. Draw a Swing JTextField component at the right of Label 1 to extend across the rest of the panel.

  5. Fill the rest of panel 3 with a Swing JTextArea, as shown below.

    Note: Swing components with a text property have a default text value entered into the text property. You can remove this by highlighting the text displayed in the text property value and pressing Delete.

This is what your UI should look like now:

Save your work again.

Tutorial Step 5 Step 7