Java examples for Swing:JComponent
add Space To Container
//package com.java2s; import javax.swing.*; import java.awt.*; public class Main { public static final int SPACE_WIDTH = new JLabel(" ") .getPreferredSize().width;//from ww w . j av a 2 s.c o m public static void addSpaceTo(Container container, int spaceSize) { JLabel label = new JLabel(); label.setPreferredSize(new Dimension(spaceSize * SPACE_WIDTH, 0)); container.add(label); } }