home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-12-14 | 1.8 KB | 75 lines |
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
-
- public class BorderLayout1 extends JPanel
- {
-
- //The constructor initializes the application
-
- public BorderLayout1()
- {
- JButton btnNorth;
- JButton btnSouth;
- JButton btnEast;
- JButton btnWest;
- JButton btnCenter;
-
- Font font1;
-
- font1 = new Font("Times-Roman",Font.BOLD,18);
-
- this.setLayout(new BorderLayout());
-
- btnNorth = new JButton("North");
- btnNorth.setFont(font1);
- add(btnNorth, "North");
-
- btnSouth = new JButton("South");
- btnSouth.setFont(font1);
- add(btnSouth, "South");
-
- btnEast = new JButton("East");
- btnEast.setFont(font1);
- add(btnEast, "East");
-
- btnWest = new JButton("West");
- btnWest.setFont(font1);
- add( btnWest, "West");
-
- btnCenter = new JButton("Center");
- btnCenter.setFont(font1);
- add(btnCenter, "Center");
-
- }//constructor
-
- //main entry point for the application
- public static void main(String s[])
- {
- JFrame f = new JFrame("Border Layout");
- BorderLayout1 panel = new BorderLayout1();
-
- f.setForeground(Color.black);
- f.setBackground(Color.lightGray);
- f.getContentPane().add(panel,"Center");
-
- f.setSize(400, 150);
- f.setVisible(true);
- f.addWindowListener(new WindowCloser());
-
- }//main
- }//class
-
-
- //This class handles the closing of the application
- class WindowCloser extends WindowAdapter
- {
- public void windowClosing(WindowEvent e)
- {
- Window win = e.getWindow();
- win.setVisible(false);
- win.dispose();
- System.exit(0);
- }//windowClosing
- }//class WindowCloser
-