Example usage for javax.swing BoxLayout getAxis

List of usage examples for javax.swing BoxLayout getAxis

Introduction

In this page you can find the example usage for javax.swing BoxLayout getAxis.

Prototype

public final int getAxis() 

Source Link

Document

Returns the axis that was used to lay out components.

Usage

From source file:Main.java

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.Y_AXIS);
    System.out.println(layout.getAxis() == BoxLayout.Y_AXIS);
    container.setLayout(layout);/*from   w w  w .  j ava2 s .  c  o m*/

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

    frame.add(container, BorderLayout.CENTER);

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