home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / inprise / JSAMPLES.Z / BorderPanel.java < prev    next >
Text File  |  1998-05-08  |  4KB  |  103 lines

  1. /*
  2.  * @(#)BorderPanel.java    1.4 98/01/31
  3.  *
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  *
  19.  */
  20.  
  21. import com.sun.java.swing.*;
  22.  
  23. import java.awt.Panel;
  24. import java.awt.Color;
  25. import java.awt.BorderLayout;
  26. import java.awt.GridLayout;
  27. import java.awt.Font;
  28.  
  29. import com.sun.java.swing.event.*;
  30. import com.sun.java.swing.border.*;
  31.  
  32. /*
  33.  * @version 1.4 01/31/98
  34.  * @author Dave Kloba
  35.  */
  36. public class BorderPanel extends JPanel      {
  37.  
  38.     public BorderPanel()    {
  39.         JLabel l;
  40.         JPanel tp;
  41.     GridLayout g;
  42.  
  43.         setLayout(new BorderLayout());
  44.         tp = new JPanel();
  45.     g = new GridLayout(0, 2);
  46.     g.setHgap(3);
  47.     g.setVgap(1);
  48.         tp.setLayout(g);
  49.  
  50.  
  51.         tp.add(new BorderLabel("LineBorder", 
  52.                                new LineBorder(Color.darkGray, 2)));
  53.         tp.add(new BorderLabel("BevelBorder RAISED",
  54.                                BorderFactory.createRaisedBevelBorder()));
  55.         tp.add(new BorderLabel("BevelBorder LOWERED", 
  56.                                BorderFactory.createLoweredBevelBorder()));
  57.         tp.add(new BorderLabel("EtchedBorder",
  58.                                BorderFactory.createEtchedBorder()));
  59.         tp.add(new BorderLabel("TitledBorder 1",
  60.                                new TitledBorder(LineBorder.createBlackLineBorder(),
  61.                                "Using LineBorder")));
  62.         tp.add(new BorderLabel("TitledBorder 2",
  63.                                new TitledBorder(BorderFactory.createRaisedBevelBorder(),
  64.                                "Using BevelBorder")));
  65.         tp.add(new BorderLabel("TitledBorder 3",
  66.                                 new TitledBorder(
  67.                                     new TitledBorder(LineBorder.createBlackLineBorder(),
  68.                                         "Using a TitledBorder"),
  69.                                     "as the Border",
  70.                                 TitledBorder.RIGHT ,
  71.                                 TitledBorder.BOTTOM )));
  72.  
  73.         tp.add(new BorderLabel("TitledBorder 4",
  74.                          new TitledBorder(new LineBorder(Color.black, 1), 
  75.                                 "Using Courier 16 bold",
  76.                                  TitledBorder.LEFT,
  77.                                  TitledBorder.TOP,
  78.                                  new Font("Courier", Font.BOLD, 16))));
  79.  
  80.         tp.add(new BorderLabel("TitledBorder 5",
  81.                                new TitledBorder(new EmptyBorder(1, 1, 1, 1),
  82.                                "Using EmptyBorder",
  83.                                TitledBorder.LEFT , TitledBorder.TOP )));
  84.  
  85.         tp.add(new BorderLabel("Matte Border",
  86.                                new MatteBorder(18,18,18,18, 
  87.                                    SwingSet.sharedInstance().loadImageIcon("images/swirl.gif","Swirl"))));
  88.  
  89.  
  90.         add(tp, BorderLayout.CENTER);
  91.  
  92.  
  93.     }
  94. }
  95.  
  96. class BorderLabel extends JLabel {
  97.     public BorderLabel(String text, Border b) {
  98.         super(text);
  99.         setBorder(b);
  100.         setHorizontalAlignment(SwingConstants.CENTER);
  101.     }
  102. }
  103.