You are here: Home / Topics / Program to use Insets in Java

Program to use Insets in Java

Filed under: Java on 2023-10-25 06:44:35

// Program to use Insets.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code="InsetsDemo" width="300" height="150">
</applet>
*/

public class InsetsDemo extends Applet 
{
Button b1, b2, b3, b4, b5;

public void init() 
{
 setLayout(new BorderLayout());

 b1 = new Button("Button-1");
 b2 = new Button("Button-2");
 b3 = new Button("Button-3");
 b4 = new Button("Button-4");
 b5 = new Button("Button-5");

 add(b1, BorderLayout.NORTH);
 add(b2, BorderLayout.SOUTH);
 add(b3, BorderLayout.EAST);
 add(b4, BorderLayout.WEST);
 add(b5, BorderLayout.CENTER);
}

public Insets getInsets()
{
 return new Insets(5, 20, 15, 30);
}
}

About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.