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

createRigidArea(dimension)

.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;
     BoxLayout()
    {
        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"));
        add(b);
     }
}
    class RigidAreaJavaExample
    {
       public static void main(String args[])
       {
           BoxLayout frame = new BoxLayout();
           frame.setTitle("RigidArea Java Example");
           frame.setBounds(200,250,250,250);
           frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           frame.setVisible(true);
       }
    }

Rigid Area Filler in Java Swing Example



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles