source file name: SwingBorderDemo.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class SwingBorderDemo extends JFrame
{
ImageIcon cen=new ImageIcon("center.png");
public static void main (String ob[])
{
SwingBorderDemo f=new SwingBorderDemo();
f.setTitle(" Swing Button Border Layout Program");
f.setSize(300,400);
f.setVisible(true);
}
public SwingBorderDemo()
{
BorderLayout bl=new BorderLayout(20,20);
setLayout(bl);
Button b1=new Button("East");
Button b2=new Button("West");
Button b3=new Button("South");
Button b4=new Button("North");
JButton b5=new JButton(cen);
add(b1,BorderLayout.EAST);
add(b2,BorderLayout.WEST);
add(b3,BorderLayout.SOUTH);
add(b4,BorderLayout.NORTH);
add(b5,BorderLayout.CENTER);
}
}
output:
0 Comments
Post a Comment