add Space To Container - Java Swing

Java examples for Swing:JComponent

Description

add Space To Container

Demo Code


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

Related Tutorials