src/java.desktop/share/classes/javax/swing/border/TitledBorder.java

Print this page




  83      */
  84     protected int titlePosition;
  85     /**
  86      * The justification for the title.
  87      */
  88     protected int titleJustification;
  89     /**
  90      * The font for rendering the title.
  91      */
  92     protected Font titleFont;
  93     /**
  94      * The color of the title.
  95      */
  96     protected Color titleColor;
  97 
  98     private final JLabel label;
  99 
 100     /**
 101      * Use the default vertical orientation for the title text.
 102      */
 103     static public final int     DEFAULT_POSITION        = 0;
 104     /** Position the title above the border's top line. */
 105     static public final int     ABOVE_TOP               = 1;
 106     /** Position the title in the middle of the border's top line. */
 107     static public final int     TOP                     = 2;
 108     /** Position the title below the border's top line. */
 109     static public final int     BELOW_TOP               = 3;
 110     /** Position the title above the border's bottom line. */
 111     static public final int     ABOVE_BOTTOM            = 4;
 112     /** Position the title in the middle of the border's bottom line. */
 113     static public final int     BOTTOM                  = 5;
 114     /** Position the title below the border's bottom line. */
 115     static public final int     BELOW_BOTTOM            = 6;
 116 
 117     /**
 118      * Use the default justification for the title text.
 119      */
 120     static public final int     DEFAULT_JUSTIFICATION   = 0;
 121     /** Position title text at the left side of the border line. */
 122     static public final int     LEFT                    = 1;
 123     /** Position title text in the center of the border line. */
 124     static public final int     CENTER                  = 2;
 125     /** Position title text at the right side of the border line. */
 126     static public final int     RIGHT                   = 3;
 127     /** Position title text at the left side of the border line
 128      *  for left to right orientation, at the right side of the
 129      *  border line for right to left orientation.
 130      */
 131     static public final int     LEADING = 4;
 132     /** Position title text at the right side of the border line
 133      *  for left to right orientation, at the left side of the
 134      *  border line for right to left orientation.
 135      */
 136     static public final int     TRAILING = 5;
 137 
 138     /**
 139      * Space between the border and the component's edge
 140      */
 141     static protected final int EDGE_SPACING = 2;
 142 
 143     /**
 144      * Space between the border and text
 145      */
 146     static protected final int TEXT_SPACING = 2;
 147 
 148     /**
 149      * Horizontal inset of text that is left or right justified
 150      */
 151     static protected final int TEXT_INSET_H = 5;
 152 
 153     /**
 154      * Creates a TitledBorder instance.
 155      *
 156      * @param title  the title the border should display
 157      */
 158     public TitledBorder(String title) {
 159         this(null, title, LEADING, DEFAULT_POSITION, null, null);
 160     }
 161 
 162     /**
 163      * Creates a TitledBorder instance with the specified border
 164      * and an empty title.
 165      *
 166      * @param border  the border
 167      */
 168     public TitledBorder(Border border) {
 169         this(border, "", LEADING, DEFAULT_POSITION, null, null);
 170     }
 171 




  83      */
  84     protected int titlePosition;
  85     /**
  86      * The justification for the title.
  87      */
  88     protected int titleJustification;
  89     /**
  90      * The font for rendering the title.
  91      */
  92     protected Font titleFont;
  93     /**
  94      * The color of the title.
  95      */
  96     protected Color titleColor;
  97 
  98     private final JLabel label;
  99 
 100     /**
 101      * Use the default vertical orientation for the title text.
 102      */
 103     public static final int     DEFAULT_POSITION        = 0;
 104     /** Position the title above the border's top line. */
 105     public static final int     ABOVE_TOP               = 1;
 106     /** Position the title in the middle of the border's top line. */
 107     public static final int     TOP                     = 2;
 108     /** Position the title below the border's top line. */
 109     public static final int     BELOW_TOP               = 3;
 110     /** Position the title above the border's bottom line. */
 111     public static final int     ABOVE_BOTTOM            = 4;
 112     /** Position the title in the middle of the border's bottom line. */
 113     public static final int     BOTTOM                  = 5;
 114     /** Position the title below the border's bottom line. */
 115     public static final int     BELOW_BOTTOM            = 6;
 116 
 117     /**
 118      * Use the default justification for the title text.
 119      */
 120     public static final int     DEFAULT_JUSTIFICATION   = 0;
 121     /** Position title text at the left side of the border line. */
 122     public static final int     LEFT                    = 1;
 123     /** Position title text in the center of the border line. */
 124     public static final int     CENTER                  = 2;
 125     /** Position title text at the right side of the border line. */
 126     public static final int     RIGHT                   = 3;
 127     /** Position title text at the left side of the border line
 128      *  for left to right orientation, at the right side of the
 129      *  border line for right to left orientation.
 130      */
 131     public static final int     LEADING = 4;
 132     /** Position title text at the right side of the border line
 133      *  for left to right orientation, at the left side of the
 134      *  border line for right to left orientation.
 135      */
 136     public static final int     TRAILING = 5;
 137 
 138     /**
 139      * Space between the border and the component's edge
 140      */
 141     protected static final int EDGE_SPACING = 2;
 142 
 143     /**
 144      * Space between the border and text
 145      */
 146     protected static final int TEXT_SPACING = 2;
 147 
 148     /**
 149      * Horizontal inset of text that is left or right justified
 150      */
 151     protected static final int TEXT_INSET_H = 5;
 152 
 153     /**
 154      * Creates a TitledBorder instance.
 155      *
 156      * @param title  the title the border should display
 157      */
 158     public TitledBorder(String title) {
 159         this(null, title, LEADING, DEFAULT_POSITION, null, null);
 160     }
 161 
 162     /**
 163      * Creates a TitledBorder instance with the specified border
 164      * and an empty title.
 165      *
 166      * @param border  the border
 167      */
 168     public TitledBorder(Border border) {
 169         this(border, "", LEADING, DEFAULT_POSITION, null, null);
 170     }
 171