by Dinesh Thakur Category: Swing

A rigid area filler is similar to pair of struts. It is an invisible component with a specific width and height. It can be created using the static method


.in the Box class. Here the dimension argument specifies the size of rigid area. For example, the statement.

b.add(Box.createRigidArea(new Dimension(10,20));

adds a rigid area 10 pixels wide and 20 pixels in height into a Box.

import javax.swing.*;

import java.awt.*;
class BoxLayout extends JFrame
     JButton [] Buttons;
        int i;
        Box b = Box.createVerticalBox();
        b.add(new JButton("C"));
        b.add(Box.createRigidArea(new Dimension(10,20)));
        b.add(new JButton("C++"));
        b.add(new JButton("Visual Basic"));
        b.add(new JButton("Java"));
    class RigidAreaJavaExample
       public static void main(String args[])
           BoxLayout frame = new BoxLayout();
           frame.setTitle("RigidArea Java Example");

Rigid Area Filler in Java Swing Example

Popular Article