Here you can find the source of createBox(int axis, Object... children)
private static Box createBox(int axis, Object... children)
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.awt.Component; import java.awt.Dimension; import javax.swing.Box; import javax.swing.BoxLayout; public class Main { private static Box createBox(int axis, Object... children) { if (axis != BoxLayout.X_AXIS && axis != BoxLayout.Y_AXIS) throw new IllegalArgumentException(); boolean horizontal = (axis == BoxLayout.X_AXIS); Box box = new Box(axis); for (Object child : children) { if (child instanceof Component) { box.add((Component) child); } else if (child instanceof Dimension) { box.add(Box.createRigidArea((Dimension) child)); } else if (child == null) { box.add(horizontal ? Box.createHorizontalGlue() : Box.createVerticalGlue()); } else if (child instanceof Integer) { int strut = (Integer) child; box.add(horizontal ? Box.createHorizontalStrut(strut) : Box.createVerticalStrut(strut)); } else { throw new ClassCastException( "Child must be component or invisible box specification (strut=integer, rigid area=dimension, glue=null)"); }/*from w w w. j a v a 2 s. com*/ } return box; } }