Filler in BoxLayout - Java Swing

Java examples for Swing:BoxLayout

Introduction

A filler is an invisible custom component.

You can create a filler by specifying its minimum, maximum, and preferred sizes.

The Filler static nested class of the Box class represents a filler.

import java.awt.Dimension;

import javax.swing.Box;

public class Main {
  public static void main(String[] argv) throws Exception {
    Dimension minSize = new Dimension(0, 0);
    Dimension prefSize = new Dimension(0, 0);
    Dimension maxSize = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
    Box.Filler filler = new Box.Filler(minSize, prefSize, maxSize);

  }
}

The following snippet of code creates a filler area of 10x10:

import java.awt.Dimension;

import javax.swing.Box;
import javax.swing.JComponent;

public class Main {
  public static void main(String[] argv) throws Exception {
    // Create a 10x10 rigid area
    Dimension d = new Dimension(10, 10);
    JComponent rigidArea = new Box.Filler(d, d, d);

  }
}

Related Tutorials