What is BoxLayout strut - Java Swing

Java examples for Swing:BoxLayout

Introduction

A strut is an invisible component of a fixed width or a fixed height.

import javax.swing.Box;
import javax.swing.JButton;

public class Main {
  public static void main(String[] argv) throws Exception {
    Box hBox = Box.createHorizontalBox();
    hBox.add(new JButton("First"));
    // Add a 100px strut to a horizontal box
    hBox.add(Box.createHorizontalStrut(100));

    hBox.add(new JButton("Last"));

  }
}

Related Tutorials