Example usage for java.awt Component BOTTOM_ALIGNMENT

List of usage examples for java.awt Component BOTTOM_ALIGNMENT

Introduction

In this page you can find the example usage for java.awt Component BOTTOM_ALIGNMENT.

Prototype

float BOTTOM_ALIGNMENT

To view the source code for java.awt Component BOTTOM_ALIGNMENT.

Click Source Link

Document

Ease-of-use constant for getAlignmentY .

Usage

From source file:AlignY.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Y Alignment");
    JPanel contentPane = (JPanel) frame.getContentPane();

    BoxLayout layout = new BoxLayout(contentPane, BoxLayout.X_AXIS);
    contentPane.setLayout(layout);// ww w .j a  va2 s.  c  o m

    JButton button = new JButton("0.0");
    button.setAlignmentY(Component.TOP_ALIGNMENT);
    contentPane.add(button);
    button = new JButton("1.0");
    button.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    contentPane.add(button);
    button = new JButton("0.5");
    button.setAlignmentY(Component.CENTER_ALIGNMENT);
    contentPane.add(button);

    frame.setSize(200, 100);
    frame.show();
}

From source file:MainClass.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.X_AXIS);
    container.setLayout(layout);//w  w w .j  ava2  s. c  o m

    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);
}

From source file:XAxisAlignY.java

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

    Container panel1 = makeIt("Top", Component.TOP_ALIGNMENT);
    Container panel2 = makeIt("Center", Component.CENTER_ALIGNMENT);
    Container panel3 = makeIt("Bottom", Component.BOTTOM_ALIGNMENT);

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 3));
    contentPane.add(panel1);//from   ww  w.  j  a  v a 2  s.co m
    contentPane.add(panel2);
    contentPane.add(panel3);

    frame.setSize(423, 171);
    frame.setVisible(true);
}

From source file:XAxisAlignY.java

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

    Container panel1 = layoutComponents("Top", Component.TOP_ALIGNMENT);
    Container panel2 = layoutComponents("Center", Component.CENTER_ALIGNMENT);
    Container panel3 = layoutComponents("Bottom", Component.BOTTOM_ALIGNMENT);

    frame.setLayout(new GridLayout(1, 3));
    frame.add(panel1);/*from w ww  . j  a  va  2 s .c om*/
    frame.add(panel2);
    frame.add(panel3);

    frame.setSize(400, 150);
    frame.setVisible(true);
}

From source file:XAxisDiffAlign.java

private static Container makeIt(String title, boolean more) {
    JPanel container = new JPanel() {
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            Insets insets = getInsets();
            int width = getWidth();
            int height = getHeight() - insets.top - insets.bottom;
            int halfHeight = height / 2 + insets.top;
            g.drawLine(0, halfHeight, width, halfHeight);
        }//from w w  w .j  av a  2s.  c  o m
    };
    container.setBorder(BorderFactory.createTitledBorder(title));
    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
    container.setLayout(layout);

    JButton button;
    button = new JButton("0.0");
    button.setOpaque(false);
    button.setAlignmentY(Component.TOP_ALIGNMENT);
    container.add(button);
    if (more) {
        button = new JButton(".25");
        button.setOpaque(false);
        button.setAlignmentY(0.25f);
        container.add(button);
        button = new JButton(".5");
        button.setOpaque(false);
        button.setAlignmentY(Component.CENTER_ALIGNMENT);
        container.add(button);
        button = new JButton(".75");
        button.setOpaque(false);
        button.setAlignmentY(0.75f);
        container.add(button);
    }
    button = new JButton("1.0");
    button.setOpaque(false);
    button.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    container.add(button);

    return container;
}

From source file:Main.java

/** Make the given components vertically-bottom aligned. */
public static void setBottomAlignment(JComponent... components) {
    setAlignmentY(Component.BOTTOM_ALIGNMENT, components);
}

From source file:lisong_mechlab.view.graphs.DamageGraph.java

/**
 * Creates and displays the {@link DamageGraph}.
 * //from w  w  w  .jav a  2 s  . com
 * @param aLoadout
 *            Which load out the diagram is for.
 * @param anXbar
 *            A {@link MessageXBar} to listen for changes to the loadout on.
 * @param aMaxSustainedDpsMetric
 *            A {@link MaxSustainedDPS} instance to use in calculation.
 */
public DamageGraph(LoadoutBase<?> aLoadout, MessageXBar anXbar, MaxSustainedDPS aMaxSustainedDpsMetric) {
    super("Max Sustained DPS over range for " + aLoadout);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    anXbar.attach(this);

    loadout = aLoadout;
    maxSustainedDPS = aMaxSustainedDpsMetric;
    chartPanel = new ChartPanel(makechart());
    setContentPane(chartPanel);
    chartPanel.getChart().getLegend().setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chartPanel.getChart().getLegend().setVerticalAlignment(VerticalAlignment.TOP);

    LegendTitle legendTitle = chartPanel.getChart().getLegend();
    XYTitleAnnotation titleAnnotation = new XYTitleAnnotation(0.98, 0.98, legendTitle,
            RectangleAnchor.TOP_RIGHT);
    titleAnnotation.setMaxWidth(0.4);
    ((XYPlot) (chartPanel.getChart().getPlot())).addAnnotation(titleAnnotation);
    chartPanel.getChart().removeLegend();

    chartPanel.setLayout(new OverlayLayout(chartPanel));
    JButton button = new JButton(
            new OpenHelp("What is this?", "Max-sustained-dps-graph", KeyStroke.getKeyStroke('w')));
    button.setMargin(new Insets(10, 10, 10, 10));
    button.setFocusable(false);
    button.setAlignmentX(Component.RIGHT_ALIGNMENT);
    button.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    chartPanel.add(button);

    setIconImage(ProgramInit.programIcon);
    setSize(800, 600);
    setVisible(true);
}

From source file:hermes.browser.actions.AbstractFIXBrowserDocumentComponent.java

protected JPanel getStatusPanel() {
    if (statusPanel == null) {
        statusPanel = new JPanel();
        statusPanel.setLayout(new java.awt.BorderLayout());
        statusPanel.setAlignmentY(java.awt.Component.BOTTOM_ALIGNMENT);

        statusMessage.setText("Reading...");
        statusMessage.setBorder(new EtchedBorder());

        statusPanel.add(statusMessage);//from   ww w .j  a  v a2  s  .co  m
    }

    return statusPanel;
}