Java Swing BorderLayout layoutCompactHorizontal(JComponent... list)

Here you can find the source of layoutCompactHorizontal(JComponent... list)

Description

Compact horizontal layout.

License

BSD License

Declaration


public static JComponent layoutCompactHorizontal(JComponent... list) 

Method Source Code

//package com.java2s;
/***/*from   w  w w .  ja v a 2s.  com*/
 * Copyright (C) 2010 Johan Henriksson
 * This code is under the Endrov / BSD license. See www.endrov.net
 * for the full text and how to cite.
 */

import java.awt.BorderLayout;

import javax.swing.*;

public class Main {
    /**
     * Compact horizontal layout. No restriction on equal size
     */
    /*
    public static JComponent compactHorizontal(JComponent left, JComponent right)
       {
       JPanel p=new JPanel(new BorderLayout());
       p.add(left,BorderLayout.WEST);
       p.add(right,BorderLayout.EAST);
       return p;
       }
     */
    public static JComponent layoutCompactHorizontal(JComponent... list) {
        JComponent last = list[list.length - 1];
        for (int i = list.length - 2; i >= 0; i--) {
            JPanel p = new JPanel(new BorderLayout());
            p.add(list[i], BorderLayout.WEST);
            p.add(last, BorderLayout.EAST);
            last = p;
        }
        return last;
        /*      JPanel p=new JPanel(new BorderLayout());
         p.add(left,BorderLayout.WEST);
         p.add(right,BorderLayout.EAST);
         return p;*/
    }
}

Related

  1. addToVerticalBorderLayout(JComponent north, JComponent center, JComponent south)
  2. createBorderLayoutPane(Object... args)
  3. createBox(Border border, Component center, Component north)
  4. createPanel(Component comp, boolean setBorder, int borderType)
  5. createPanel(JComponent centerComponent, JComponent placedComponent, String borderLayoutConstraint)
  6. layoutCompactVertical(JComponent... list)
  7. makeBorderPanel(int topMargin, int leftMargin, int bottomMargin, int rightMargin)
  8. makeLateralBorders(JPanel panel, Dimension reference, Border style)
  9. wrapInBorderPanel(final JComponent component)