SourceForge.net Logo

Close Button

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 title
    cts.attachToComponent(TOP, ELASTIC, 5, title, BOTTOM);

    // Center between two thirds of the panel's width and right edge
    cts.attachToRelativePosition(LEFT, ELASTIC, 2, 67);
    cts.attachToBorder(RIGHT, ELASTIC, 5);

    // Attach to panel bottom
    cts.attachToBorder(BOTTOM, FIXED, 5);

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

    panel.add(button_close, cts);