The Insets Class - Java Swing

Java examples for Swing:Insets

Introduction

Insets class represents spaces that are left around a container.

Insets class has four properties named top, left, bottom, and right.

Insets class is in the java.awt package.

Demo Code

import java.awt.Insets;

import javax.swing.JFrame;

public class Main {
  public static void main(String[] argv) throws Exception {
    // Create an object of the Insets class
    // with Insets(top, left, bottom, right)
    Insets ins = new Insets(20, 5, 5, 5);
    JFrame frame = new JFrame("title");
    // Get the insets of a JFrame
    ins = frame.getInsets();// ww w . j  av a2s. c o m
    int top = ins.top;
    int left = ins.left;
    int bottom = ins.bottom;
    int right = ins.right;
  }
}

Related Tutorials