align Components Base Horizontal - Java java.awt

Java examples for java.awt:Component

Description

align Components Base Horizontal

Demo Code

// Copyright (c) 1996 - 1999, 2003 by Yoshiki Shibata. All rights reserved.
//package com.java2s;
import java.awt.Component;

import java.awt.Rectangle;

public class Main {
    static public void alignComponentsBaseHorizontal(Component left,
            Component right) {//from w  w w.  ja v a2 s  .c om
        Rectangle leftBounds = left.getBounds();
        Rectangle rightBounds = right.getBounds();

        leftBounds.y = rightBounds.y + rightBounds.height
                - leftBounds.height;
        left.setBounds(leftBounds);
    }
}

Related Tutorials