Chris Rathman / ChrisRath@aol.com

/************************************************************************
 *                                                                      *
 * javax.swing_border                                                   *
 *                                                                      *
 *    Interfaces:                                                       *
 *       Border                                                         *
 *                                                                      *
 *    Classes:                                                          *
 *       AbstractBorder                  LineBorder                     *
 *       BevelBorder                     MatteBorder                    *
 *       CompoundBorder                  SoftBevelBorder                *
 *       EmptyBorder                     TitledBorder                   *
 *       EtchedBorder                                                   *
 *                                                                      *
 ************************************************************************/
package Test.Chris;
import javax.swing.border.*;

public class Javax_swing_border {

   public static void main(String[] args) {
      Javax_swing_border obj = new Javax_swing_border();
      obj.jframe();
      System.exit(0);
   }

   private javax.swing.JFrame myFrame = new javax.swing.JFrame("Test Frame");
   private boolean myFrameActive = true;
   void jframe() {
      border();
      abstractborder();
      bevelborder();
      compoundborder();
      emptyborder();
      etchedborder();
      lineborder();
      matteborder();
      softbevelborder();
      titledborder();

      myFrame.getContentPane().setLayout(new java.awt.FlowLayout());
      myFrame.pack();
      myFrame.setSize(400, 400);
      myFrame.setLocation(200, 200);
      myFrame.show();
      myFrame.toFront();
      myFrame.addWindowListener(
         new java.awt.event.WindowListener() {
            public void windowActivated(java.awt.event.WindowEvent e) { }
            public void windowClosed(java.awt.event.WindowEvent e) { }
            public void windowClosing(java.awt.event.WindowEvent e) { myFrameActive = false; }
            public void windowDeactivated(java.awt.event.WindowEvent e) { }
            public void windowDeiconified(java.awt.event.WindowEvent e) { }
            public void windowIconified(java.awt.event.WindowEvent e) { }
            public void windowOpened(java.awt.event.WindowEvent e) { }
         });
      while (myFrameActive) {
         try { Thread.sleep(250); } catch(InterruptedException e) { }
      }
      myFrame.dispose();                           // disposes of the frame
   }

   /*********************************************************************
    *                                                                   *
    * Border:                                                           *
    *                                                                   *
    *    Methods:                                                       *
    *       getBorderInsets      isBorderOpaque       paintBorder       *
    *                                                                   *
    *********************************************************************/
   void border() {
      boolean f;
      java.awt.Insets n;

      javax.swing.JButton c = new javax.swing.JButton("Border");
      myFrame.getContentPane().add(c);
      Border b = c.getBorder();

      f = b.isBorderOpaque();                     // Returns whether or not the border is opaque.
      n = b.getBorderInsets(c);                   // Returns the insets of the border.
   /*
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height);     // Paints the border for the specified component with the specified position and size.
   */
   }

   /*********************************************************************
    *                                                                   *
    * AbstractBorder:                                                   *
    *                                                                   *
    *    Methods:                                                       *
    *       getBorderInsets                  isBorderOpaque             *
    *       getInteriorRectangle             paintBorder                *
    *                                                                   *
    *********************************************************************/
   void abstractborder() {
      boolean f;
      java.awt.Insets n;

      javax.swing.JButton c = new javax.swing.JButton("AbstractBorder");
      myFrame.getContentPane().add(c);
      AbstractBorder b = (AbstractBorder)c.getBorder();

      f = b.isBorderOpaque();                      // This default implementation returns false.
      n = b.getBorderInsets(c);                    // This default implementation returns the value of getBorderMargins.
      n = b.getBorderInsets(c, n);                 // Reinitialize the insets parameter with this Border's current Insets.
   /*
      static Rectangle getInteriorRectangle(Component c, Border b, int x, int y, int width, int height);    // This method returns a rectangle using the arguements minus the insets of the border.
      Rectangle getInteriorRectangle(Component c, int x, int y, int width, int height);      // This is a convience method that calls the static method.
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height)      // This default implementation does no painting.
   */
   }

   /*********************************************************************
    *                                                                   *
    * BevelBorder:                                                      *
    *                                                                   *
    *    Fields:                                                        *
    *      $bevelType                       $shadowInner                *
    *      $highlightInner                  $shadowOuter                *
    *      $highlightOuter                                              *
    *       LOWERED                          RAISED                     *
    *                                                                   *
    *    Methods:                                                       *
    *       getBevelType                     getShadowOuterColor        *
    *       getBorderInsets                  isBorderOpaque             *
    *       getHighlightInnerColor           paintBorder                *
    *       getHighlightOuterColor          $paintLoweredBevel          *
    *       getShadowInnerColor             $paintRaisedBevel           *
    *                                                                   *
    *********************************************************************/
   void bevelborder() {
      int i;
      boolean f;
      java.awt.Color g;
      java.awt.Insets n;
      BevelBorder b = new BevelBorder(BevelBorder.RAISED);

      javax.swing.JButton c = new javax.swing.JButton("BevelBorder");
      myFrame.getContentPane().add(c);
      c.setBorder(b);

      i = b.getBevelType();                     // Returns the type of the bevel border.
      switch (i) {
         case BevelBorder.LOWERED: break;       // Lowered bevel type.
         case BevelBorder.RAISED: break;        // Raised bevel type.
      }
      f = b.isBorderOpaque();                   // Returns whether or not the border is opaque.
      n = b.getBorderInsets(c);                 // Returns the insets of the border.
      n = b.getBorderInsets(c, n);              // Reinitialize the insets parameter with this Border's current Insets.
      g = b.getHighlightInnerColor(c);          // Returns the inner highlight color of the bevel border.
      g = b.getHighlightOuterColor(c);          // Returns the outer highlight color of the bevel border.
      g = b.getShadowInnerColor(c);             // Returns the inner shadow color of the bevel border.
      g = b.getShadowOuterColor(c);             // Returns the outer shadow color of the bevel border.
   /*
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height);     // Paints the border for the specified component with the specified position and size.
   */
   }

   /*********************************************************************
    *                                                                   *
    * CompoundBorder:                                                   *
    *                                                                   *
    *    Fields:                                                        *
    *      $insideBorder        $outsideBorder                          *
    *                                                                   *
    *    Methods:                                                       *
    *       getBorderInsets      getOutsideBorder     paintBorder       *
    *       getInsideBorder      isBorderOpaque                         *
    *                                                                   *
    *********************************************************************/
   void compoundborder() {
      boolean f;
      java.awt.Insets n;
      Border ob;
      CompoundBorder b = new CompoundBorder(new EtchedBorder(), new BevelBorder(BevelBorder.RAISED));

      javax.swing.JButton c = new javax.swing.JButton("CompoundBorder");
      myFrame.getContentPane().add(c);
      c.setBorder(b);

      f = b.isBorderOpaque();             // Returns whether or not this compound border is opaque.
      n = b.getBorderInsets(c);           // Returns the insets of the composite border by adding the insets of the outside border to the insets of the inside border.
      n = b.getBorderInsets(c, n);        // Reinitialize the insets parameter with this Border's current Insets.
      ob = b.getInsideBorder();           // Returns the inside border object.
      ob = b.getOutsideBorder();          // Returns the outside border object.
   /*
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height);     // Paints the compound border by painting the outside border with the specified position and size and then painting the inside border at the specified position and size offset by the insets of the outside border.
   */
   }

   /*********************************************************************
    *                                                                   *
    * EmptyBorder:                                                      *
    *                                                                   *
    *    Fields:                                                        *
    *      $bottom              $right               $top               *
    *      $left                                                        *
    *                                                                   *
    *    Methods:                                                       *
    *       getBorderInsets      isBorderOpaque       paintBorder       *
    *                                                                   *
    *********************************************************************/
   void emptyborder() {
      boolean f;
      java.awt.Insets n;
      EmptyBorder b = new EmptyBorder(10, 10, 10, 10);

      javax.swing.JButton c = new javax.swing.JButton("EmptyBorder");
      myFrame.getContentPane().add(c);
      c.setBorder(b);

      f = b.isBorderOpaque();                // Returns whether or not the border is opaque.
      n = b.getBorderInsets(c);              // Returns the insets of the border.
      n = b.getBorderInsets(c, n);           // Reinitialize the insets parameter with this Border's current Insets.
   /*
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height);     // Does no drawing by default.
   */
   }

   /*********************************************************************
    *                                                                   *
    * EtchedBorder:                                                     *
    *                                                                   *
    *    Fields:                                                        *
    *      $etchType            $shadow               LOWERED           *
    *      $highlight                                 RAISED            *
    *                                                                   *
    *    Methods:                                                       *
    *       getBorderInsets      getHighlightColor    isBorderOpaque    *
    *       getEtchType          getShadowColor       paintBorder       *
    *                                                                   *
    *********************************************************************/
   void etchedborder() {
      int i;
      boolean f;
      java.awt.Color g;
      java.awt.Insets n;
      EtchedBorder b = new EtchedBorder(EtchedBorder.RAISED);

      javax.swing.JButton c = new javax.swing.JButton("EtchedBorder");
      myFrame.getContentPane().add(c);
      c.setBorder(b);

      i = b.getEtchType();                      // Returns which etch-type is set on the etched border.
      switch (i) {
         case EtchedBorder.LOWERED: break;      // Lowered etched type.
         case EtchedBorder.RAISED: break;       // Raised etched type.
      }
      f = b.isBorderOpaque();                   // Returns whether or not the border is opaque.
      n = b.getBorderInsets(c);                 // Returns the insets of the border.
      n = b.getBorderInsets(c, n);              // Reinitialize the insets parameter with this Border's current Insets.
      g = b.getHighlightColor(c);               // Returns the highlight color of the etched border.
      g = b.getShadowColor(c);                  // Returns the shadow color of the etched border.
   /*
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height);     // Paints the border for the specified component with the specified position and size.
   */
   }

   /*********************************************************************
    *                                                                   *
    * LineBorder:                                                       *
    *                                                                   *
    *    Fields:                                                        *
    *      $lineColor           $roundedCorners      $thickness         *
    *                                                                   *
    *    Methods:                                                       *
    *       createBlackLineBorder   getLineColor      isBorderOpaque    *
    *       createGrayLineBorder    getThickness      paintBorder       *
    *       getBorderInsets                                             *
    *                                                                   *
    *********************************************************************/
   void lineborder() {
      int i;
      boolean f;
      java.awt.Color g;
      java.awt.Insets n;
      Border lb;
      LineBorder b = new LineBorder(java.awt.Color.blue, 4);

      javax.swing.JButton c = new javax.swing.JButton("LineBorder");
      myFrame.getContentPane().add(c);
      c.setBorder(b);

      lb = LineBorder.createBlackLineBorder();  // Convenience method for getting the Color.black LineBorder of thickness 1.
      lb = LineBorder.createGrayLineBorder();   // Convenience method for getting the Color.gray LineBorder of thickness 1.

      i = b.getThickness();                     // Returns the thickness of the border.
      f = b.isBorderOpaque();                   // Returns whether or not the border is opaque.
      n = b.getBorderInsets(c);                 // Returns the insets of the border.
      n = b.getBorderInsets(c, n);              // Reinitialize the insets parameter with this Border's current Insets.
      g = b.getLineColor();                     // Returns the color of the border.
   /*
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height);     // Paints the border for the specified component with the specified position and size.
   */
   }

   /*********************************************************************
    *                                                                   *
    * MatteBorder:                                                      *
    *                                                                   *
    *    Fields:                                                        *
    *      $color                                                       *
    *      $tileIcon                                                    *
    *                                                                   *
    *    Methods:                                                       *
    *       getBorderInsets      isBorderOpaque       paintBorder       *
    *                                                                   *
    *********************************************************************/
   void matteborder() {
      boolean f;
      java.awt.Insets n;
      MatteBorder b = new MatteBorder(10, 10, 10, 10, java.awt.Color.blue);

      javax.swing.JButton c = new javax.swing.JButton("MatteBorder");
      myFrame.getContentPane().add(c);
      c.setBorder(b);

      n = b.getBorderInsets(c);           // Returns the insets of the border.
      f = b.isBorderOpaque();             // Returns whether or not the border is opaque.
   /*
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height);     // Paints the matte border.
   */
   }

   /*********************************************************************
    *                                                                   *
    * SoftBevelBorder:                                                  *
    *                                                                   *
    *    Fields:                                                        *
    *                                                                   *
    *    Methods:                                                       *
    *       getBorderInsets      isBorderOpaque       paintBorder       *
    *                                                                   *
    *********************************************************************/
   void softbevelborder() {
      boolean f;
      java.awt.Insets n;
      SoftBevelBorder b = new SoftBevelBorder(SoftBevelBorder.RAISED);

      javax.swing.JButton c = new javax.swing.JButton("SoftBevelBorder");
      myFrame.getContentPane().add(c);
      c.setBorder(b);

      f = b.isBorderOpaque();             // Returns whether or not the border is opaque.
      n = b.getBorderInsets(c);           // Returns the insets of the border.
   /*
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height);     // Paints the border for the specified component with the specified position and size.
   */
   }

   /*********************************************************************
    *                                                                   *
    * TitledBorder:                                                     *
    *                                                                   *
    *    Fields:                                                        *
    *       ABOVE_BOTTOM    DEFAULT_JUSTIFICATION $title                *
    *       ABOVE_TOP       DEFAULT_POSITION      $titleColor           *
    *       BELOW_BOTTOM   $EDGE_SPACING          $titleFont            *
    *       BELOW_TOP       LEFT                  $titleJustification   *
    *       $border         RIGHT                 $titlePosition        *
    *       BOTTOM         $TEXT_INSET_H           TOP                  *
    *       CENTER         $TEXT_SPACING                                *
    *                                                                   *
    *    Methods:                                                       *
    *       getBorder       getTitleFont           setTitle             *
    *       getBorderInsets getTitleJustification  setTitleColor        *
    *      $getFont         getTitlePosition       setTitleFont         *
    *       getMinimumSize  isBorderOpaque         setTitleJustification*
    *       getTitle        paintBorder            setTitlePosition     *
    *       getTitleColor   setBorder                                   *
    *                                                                   *
    *********************************************************************/
   void titledborder() {
      int i;
      boolean f;
      String s;
      java.awt.Dimension d;
      java.awt.Insets n;
      java.awt.Color g;
      java.awt.Font h;
      Border tb;
      TitledBorder b = new TitledBorder(new BevelBorder(BevelBorder.RAISED), "MyText");

      javax.swing.JButton c = new javax.swing.JButton("TitledBorder");
      myFrame.getContentPane().add(c);
      c.setBorder(b);

      b.setBorder(new BevelBorder(BevelBorder.RAISED));  // Sets the border of the titled border.
      b.setTitle("MyText");                              // Sets the title of the titled border.
      b.setTitleColor(java.awt.Color.blue);              // Sets the title-color of the titled border.
      b.setTitleFont(new java.awt.Font("Dialog",
         java.awt.Font.PLAIN, 12));                      // Sets the title-font of the titled border.
      b.setTitleJustification(TitledBorder.CENTER);      // Sets the title-justification of the titled border.
      b.setTitlePosition(TitledBorder.ABOVE_TOP);        // Sets the title-position of the titled border.

      tb = b.getBorder();                                // Returns the border of the titled border.
      n = b.getBorderInsets(c);                          // Returns the insets of the border.
      n = b.getBorderInsets(c, n);                       // Reinitialize the insets parameter with this Border's current Insets.
      d = b.getMinimumSize(c);                           // Returns the minimum dimensions this border requires in order to fully display the border and title.
      s = b.getTitle();                                  // Returns the title of the titled border.
      g = b.getTitleColor();                             // Returns the title-color of the titled border.
      h = b.getTitleFont();                              // Returns the title-font of the titled border.
      i = b.getTitleJustification();                     // Returns the title-justification of the titled border.
      switch (i) {
         case TitledBorder.DEFAULT_JUSTIFICATION: break; // Use the default justification for the title text.
         case TitledBorder.CENTER: break;                // Position title text in the center of the border line.
         case TitledBorder.LEFT: break;                  // Position title text at the left side of the border line.
         case TitledBorder.RIGHT: break;                 // Position title text at the right side of the border line.
      }
      i = b.getTitlePosition();                          // Returns the title-position of the titled border.
      switch (i) {
         case TitledBorder.ABOVE_BOTTOM: break;          // Position the title above the border's bottom line.
         case TitledBorder.ABOVE_TOP: break;             // Position the title above the border's top line.
         case TitledBorder.BELOW_BOTTOM: break;          // Position the title below the border's bottom line.
         case TitledBorder.BELOW_TOP: break;             // Position the title below the border's top line.
         case TitledBorder.BOTTOM: break;                // Position the title in the middle of the border's bottom line.
         case TitledBorder.TOP: break;                   // Position the title in the middle of the border's top line.
         case TitledBorder.DEFAULT_POSITION: break;      // Use the default vertical orientation for the title text.
      }
      f = b.isBorderOpaque();                            // Returns whether or not the border is opaque.
   /*
      void paintBorder(Component c, Graphics g, int x, int y, int width, int height);     // Paints the border for the specified component with the specified position and size.
   */
   }
}

Chris Rathman / ChrisRath@aol.com