SourceForge.net Logo

Button 3

Click on any component (labels, buttons, text area) to see its layout code. A complete source code overview is available as well.


    // Make sure button is below label 2
    cts.attachToComponent(TOP, ELASTIC, 3, label_2, BOTTOM);

    // Make sure button is to the right of the longest label in column_1
    // Component[] column_1 = {label_1, label_2, label_3}; //deprecated
    // cts.attachToComponents(LEFT, FIXED, 3, column_1, RIGHT); //deprecated
    cts.attachToBox(LEFT, FIXED, 3, "column_1", RIGHT);

    // Align bottom with label bottom
    cts.attachToComponent(BOTTOM, FIXED, 0, label_3, BOTTOM);

    // Make sure label leaves a minimum of 120 pixels for the text area
    cts.attachToBorder(RIGHT, ELASTIC, 120);

    // Set button width
    cts.setPreferredWidth(80);

    panel.add(button_3, cts);