Component.BOTTOM_ALIGNMENT : Component « java.awt « Java by API





Component.BOTTOM_ALIGNMENT

  

import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class MainClass {

  public static void main(String[] a) {
    JFrame frame = new JFrame("Alignment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String labels[] = { "--", "----", "--------", "------------" };

    JPanel container = new JPanel();
    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
    container.setLayout(layout);

    for (int i = 0; i < labels.length; i++) {
      JButton button = new JButton(labels[i]);
      button.setAlignmentX(Component.BOTTOM_ALIGNMENT);
      container.add(button);
    }

    frame.add(container, BorderLayout.CENTER);

    frame.setSize(300, 200);
    frame.setVisible(true);
  }
}

           
         
    
  










Related examples in the same category

1.Component.CENTER_ALIGNMENT
2.Component.LEFT_ALIGNMENT
3.Component.RIGHT_ALIGNMENT
4.Component.TOP_ALIGNMENT
5.Component: enableEvents(long eventsToEnable)
6.Component: getAccessibleContext()
7.Component: getLocationOnScreen()
8.Component: isFocusable()
9.Component: isFocusCycleRoot
10.Component: requestFocusInWindow()
11.Component: setBounds(int x,int y,int width,int height)
12.Component: setComponentOrientation(ComponentOrientation o)
13.Component: setLocation(int x, int y)
14.Component: setSize(int width, int height)