0N/A/*
2362N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage javax.swing.border;
0N/A
0N/Aimport java.awt.Color;
0N/Aimport java.awt.Component;
0N/Aimport java.awt.Dimension;
0N/Aimport java.awt.Font;
0N/Aimport java.awt.Graphics;
0N/Aimport java.awt.Graphics2D;
0N/Aimport java.awt.Insets;
0N/Aimport java.awt.Rectangle;
0N/Aimport java.awt.geom.Path2D;
0N/Aimport java.beans.ConstructorProperties;
0N/Aimport javax.swing.JComponent;
0N/Aimport javax.swing.JLabel;
0N/Aimport javax.swing.UIManager;
0N/Aimport javax.swing.plaf.basic.BasicHTML;
0N/A
0N/A/**
0N/A * A class which implements an arbitrary border
0N/A * with the addition of a String title in a
0N/A * specified position and justification.
0N/A * <p>
0N/A * If the border, font, or color property values are not
0N/A * specified in the constuctor or by invoking the appropriate
0N/A * set methods, the property values will be defined by the current
0N/A * look and feel, using the following property names in the
0N/A * Defaults Table:
0N/A * <ul>
0N/A * <li>&quot;TitledBorder.border&quot;
0N/A * <li>&quot;TitledBorder.font&quot;
0N/A * <li>&quot;TitledBorder.titleColor&quot;
0N/A * </ul>
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A *
0N/A * @author David Kloba
0N/A * @author Amy Fowler
0N/A */
0N/Apublic class TitledBorder extends AbstractBorder
0N/A{
0N/A protected String title;
0N/A protected Border border;
0N/A protected int titlePosition;
0N/A protected int titleJustification;
0N/A protected Font titleFont;
0N/A protected Color titleColor;
0N/A
0N/A private final JLabel label;
0N/A
0N/A /**
0N/A * Use the default vertical orientation for the title text.
0N/A */
0N/A static public final int DEFAULT_POSITION = 0;
0N/A /** Position the title above the border's top line. */
0N/A static public final int ABOVE_TOP = 1;
0N/A /** Position the title in the middle of the border's top line. */
0N/A static public final int TOP = 2;
0N/A /** Position the title below the border's top line. */
0N/A static public final int BELOW_TOP = 3;
0N/A /** Position the title above the border's bottom line. */
0N/A static public final int ABOVE_BOTTOM = 4;
0N/A /** Position the title in the middle of the border's bottom line. */
0N/A static public final int BOTTOM = 5;
0N/A /** Position the title below the border's bottom line. */
0N/A static public final int BELOW_BOTTOM = 6;
0N/A
0N/A /**
0N/A * Use the default justification for the title text.
0N/A */
0N/A static public final int DEFAULT_JUSTIFICATION = 0;
0N/A /** Position title text at the left side of the border line. */
0N/A static public final int LEFT = 1;
0N/A /** Position title text in the center of the border line. */
0N/A static public final int CENTER = 2;
0N/A /** Position title text at the right side of the border line. */
0N/A static public final int RIGHT = 3;
0N/A /** Position title text at the left side of the border line
0N/A * for left to right orientation, at the right side of the
0N/A * border line for right to left orientation.
0N/A */
0N/A static public final int LEADING = 4;
0N/A /** Position title text at the right side of the border line
0N/A * for left to right orientation, at the left side of the
0N/A * border line for right to left orientation.
0N/A */
0N/A static public final int TRAILING = 5;
0N/A
0N/A // Space between the border and the component's edge
0N/A static protected final int EDGE_SPACING = 2;
0N/A
0N/A // Space between the border and text
0N/A static protected final int TEXT_SPACING = 2;
0N/A
0N/A // Horizontal inset of text that is left or right justified
0N/A static protected final int TEXT_INSET_H = 5;
0N/A
0N/A /**
0N/A * Creates a TitledBorder instance.
0N/A *
0N/A * @param title the title the border should display
0N/A */
0N/A public TitledBorder(String title) {
0N/A this(null, title, LEADING, DEFAULT_POSITION, null, null);
0N/A }
0N/A
0N/A /**
0N/A * Creates a TitledBorder instance with the specified border
0N/A * and an empty title.
0N/A *
0N/A * @param border the border
0N/A */
0N/A public TitledBorder(Border border) {
0N/A this(border, "", LEADING, DEFAULT_POSITION, null, null);
0N/A }
0N/A
0N/A /**
0N/A * Creates a TitledBorder instance with the specified border
0N/A * and title.
0N/A *
0N/A * @param border the border
0N/A * @param title the title the border should display
0N/A */
0N/A public TitledBorder(Border border, String title) {
0N/A this(border, title, LEADING, DEFAULT_POSITION, null, null);
0N/A }
0N/A
0N/A /**
0N/A * Creates a TitledBorder instance with the specified border,
0N/A * title, title-justification, and title-position.
0N/A *
0N/A * @param border the border
0N/A * @param title the title the border should display
0N/A * @param titleJustification the justification for the title
0N/A * @param titlePosition the position for the title
0N/A */
0N/A public TitledBorder(Border border,
0N/A String title,
0N/A int titleJustification,
0N/A int titlePosition) {
0N/A this(border, title, titleJustification,
0N/A titlePosition, null, null);
0N/A }
0N/A
0N/A /**
0N/A * Creates a TitledBorder instance with the specified border,
0N/A * title, title-justification, title-position, and title-font.
0N/A *
0N/A * @param border the border
0N/A * @param title the title the border should display
0N/A * @param titleJustification the justification for the title
0N/A * @param titlePosition the position for the title
0N/A * @param titleFont the font for rendering the title
0N/A */
0N/A public TitledBorder(Border border,
0N/A String title,
0N/A int titleJustification,
0N/A int titlePosition,
0N/A Font titleFont) {
0N/A this(border, title, titleJustification,
0N/A titlePosition, titleFont, null);
0N/A }
0N/A
0N/A /**
0N/A * Creates a TitledBorder instance with the specified border,
0N/A * title, title-justification, title-position, title-font, and
0N/A * title-color.
0N/A *
0N/A * @param border the border
0N/A * @param title the title the border should display
0N/A * @param titleJustification the justification for the title
0N/A * @param titlePosition the position for the title
0N/A * @param titleFont the font of the title
0N/A * @param titleColor the color of the title
0N/A */
0N/A @ConstructorProperties({"border", "title", "titleJustification", "titlePosition", "titleFont", "titleColor"})
0N/A public TitledBorder(Border border,
0N/A String title,
0N/A int titleJustification,
0N/A int titlePosition,
0N/A Font titleFont,
0N/A Color titleColor) {
0N/A this.title = title;
0N/A this.border = border;
0N/A this.titleFont = titleFont;
0N/A this.titleColor = titleColor;
0N/A
0N/A setTitleJustification(titleJustification);
0N/A setTitlePosition(titlePosition);
0N/A
0N/A this.label = new JLabel();
0N/A this.label.setOpaque(false);
0N/A this.label.putClientProperty(BasicHTML.propertyKey, null);
0N/A }
0N/A
0N/A /**
0N/A * Paints the border for the specified component with the
0N/A * specified position and size.
0N/A * @param c the component for which this border is being painted
0N/A * @param g the paint graphics
0N/A * @param x the x position of the painted border
0N/A * @param y the y position of the painted border
0N/A * @param width the width of the painted border
0N/A * @param height the height of the painted border
0N/A */
0N/A public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
0N/A Border border = getBorder();
0N/A String title = getTitle();
0N/A if ((title != null) && !title.isEmpty()) {
0N/A int edge = (border instanceof TitledBorder) ? 0 : EDGE_SPACING;
0N/A JLabel label = getLabel(c);
0N/A Dimension size = label.getPreferredSize();
0N/A Insets insets = getBorderInsets(border, c, new Insets(0, 0, 0, 0));
0N/A
0N/A int borderX = x + edge;
0N/A int borderY = y + edge;
0N/A int borderW = width - edge - edge;
0N/A int borderH = height - edge - edge;
0N/A
0N/A int labelY = y;
0N/A int labelH = size.height;
0N/A int position = getPosition();
0N/A switch (position) {
0N/A case ABOVE_TOP:
0N/A insets.left = 0;
0N/A insets.right = 0;
0N/A borderY += labelH - edge;
0N/A borderH -= labelH - edge;
0N/A break;
0N/A case TOP:
0N/A insets.top = edge + insets.top/2 - labelH/2;
0N/A if (insets.top < edge) {
0N/A borderY -= insets.top;
0N/A borderH += insets.top;
0N/A }
0N/A else {
0N/A labelY += insets.top;
0N/A }
0N/A break;
0N/A case BELOW_TOP:
0N/A labelY += insets.top + edge;
0N/A break;
0N/A case ABOVE_BOTTOM:
0N/A labelY += height - labelH - insets.bottom - edge;
0N/A break;
0N/A case BOTTOM:
0N/A labelY += height - labelH;
0N/A insets.bottom = edge + (insets.bottom - labelH) / 2;
0N/A if (insets.bottom < edge) {
0N/A borderH += insets.bottom;
0N/A }
0N/A else {
0N/A labelY -= insets.bottom;
0N/A }
0N/A break;
0N/A case BELOW_BOTTOM:
0N/A insets.left = 0;
0N/A insets.right = 0;
0N/A labelY += height - labelH;
0N/A borderH -= labelH - edge;
0N/A break;
0N/A }
0N/A insets.left += edge + TEXT_INSET_H;
0N/A insets.right += edge + TEXT_INSET_H;
0N/A
0N/A int labelX = x;
0N/A int labelW = width - insets.left - insets.right;
0N/A if (labelW > size.width) {
0N/A labelW = size.width;
0N/A }
0N/A switch (getJustification(c)) {
0N/A case LEFT:
0N/A labelX += insets.left;
0N/A break;
0N/A case RIGHT:
0N/A labelX += width - insets.right - labelW;
0N/A break;
0N/A case CENTER:
0N/A labelX += (width - labelW) / 2;
0N/A break;
0N/A }
0N/A
0N/A if (border != null) {
0N/A if ((position != TOP) && (position != BOTTOM)) {
0N/A border.paintBorder(c, g, borderX, borderY, borderW, borderH);
0N/A }
0N/A else {
0N/A Graphics g2 = g.create();
0N/A if (g2 instanceof Graphics2D) {
0N/A Graphics2D g2d = (Graphics2D) g2;
0N/A Path2D path = new Path2D.Float();
0N/A path.append(new Rectangle(borderX, borderY, borderW, labelY - borderY), false);
0N/A path.append(new Rectangle(borderX, labelY, labelX - borderX - TEXT_SPACING, labelH), false);
0N/A path.append(new Rectangle(labelX + labelW + TEXT_SPACING, labelY, borderX - labelX + borderW - labelW - TEXT_SPACING, labelH), false);
0N/A path.append(new Rectangle(borderX, labelY + labelH, borderW, borderY - labelY + borderH - labelH), false);
0N/A g2d.clip(path);
0N/A }
0N/A border.paintBorder(c, g2, borderX, borderY, borderW, borderH);
0N/A g2.dispose();
0N/A }
0N/A }
0N/A g.translate(labelX, labelY);
0N/A label.setSize(labelW, labelH);
0N/A label.paint(g);
0N/A g.translate(-labelX, -labelY);
0N/A }
0N/A else if (border != null) {
0N/A border.paintBorder(c, g, x, y, width, height);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Reinitialize the insets parameter with this Border's current Insets.
0N/A * @param c the component for which this border insets value applies
0N/A * @param insets the object to be reinitialized
0N/A */
0N/A public Insets getBorderInsets(Component c, Insets insets) {
0N/A Border border = getBorder();
0N/A insets = getBorderInsets(border, c, insets);
0N/A
0N/A String title = getTitle();
0N/A if ((title != null) && !title.isEmpty()) {
0N/A int edge = (border instanceof TitledBorder) ? 0 : EDGE_SPACING;
0N/A JLabel label = getLabel(c);
0N/A Dimension size = label.getPreferredSize();
0N/A
0N/A switch (getPosition()) {
0N/A case ABOVE_TOP:
0N/A insets.top += size.height - edge;
0N/A break;
0N/A case TOP: {
0N/A if (insets.top < size.height) {
0N/A insets.top = size.height - edge;
0N/A }
0N/A break;
0N/A }
0N/A case BELOW_TOP:
0N/A insets.top += size.height;
0N/A break;
0N/A case ABOVE_BOTTOM:
0N/A insets.bottom += size.height;
0N/A break;
0N/A case BOTTOM: {
0N/A if (insets.bottom < size.height) {
0N/A insets.bottom = size.height - edge;
0N/A }
0N/A break;
0N/A }
0N/A case BELOW_BOTTOM:
0N/A insets.bottom += size.height - edge;
0N/A break;
0N/A }
0N/A insets.top += edge + TEXT_SPACING;
0N/A insets.left += edge + TEXT_SPACING;
0N/A insets.right += edge + TEXT_SPACING;
0N/A insets.bottom += edge + TEXT_SPACING;
0N/A }
0N/A return insets;
0N/A }
0N/A
0N/A /**
0N/A * Returns whether or not the border is opaque.
0N/A */
0N/A public boolean isBorderOpaque() {
0N/A return false;
0N/A }
0N/A
0N/A /**
0N/A * Returns the title of the titled border.
0N/A *
0N/A * @return the title of the titled border
0N/A */
0N/A public String getTitle() {
0N/A return title;
0N/A }
0N/A
0N/A /**
0N/A * Returns the border of the titled border.
0N/A *
0N/A * @return the border of the titled border
0N/A */
0N/A public Border getBorder() {
0N/A return border != null
0N/A ? border
0N/A : UIManager.getBorder("TitledBorder.border");
0N/A }
0N/A
0N/A /**
0N/A * Returns the title-position of the titled border.
0N/A *
0N/A * @return the title-position of the titled border
0N/A */
0N/A public int getTitlePosition() {
0N/A return titlePosition;
0N/A }
0N/A
0N/A /**
0N/A * Returns the title-justification of the titled border.
0N/A *
0N/A * @return the title-justification of the titled border
0N/A */
0N/A public int getTitleJustification() {
0N/A return titleJustification;
0N/A }
0N/A
0N/A /**
0N/A * Returns the title-font of the titled border.
0N/A *
0N/A * @return the title-font of the titled border
0N/A */
0N/A public Font getTitleFont() {
0N/A return titleFont;
0N/A }
0N/A
0N/A /**
0N/A * Returns the title-color of the titled border.
0N/A *
0N/A * @return the title-color of the titled border
0N/A */
0N/A public Color getTitleColor() {
0N/A return titleColor;
0N/A }
0N/A
0N/A
0N/A // REMIND(aim): remove all or some of these set methods?
0N/A
0N/A /**
0N/A * Sets the title of the titled border.
0N/A * @param title the title for the border
0N/A */
0N/A public void setTitle(String title) {
0N/A this.title = title;
0N/A }
0N/A
0N/A /**
0N/A * Sets the border of the titled border.
0N/A * @param border the border
0N/A */
0N/A public void setBorder(Border border) {
0N/A this.border = border;
0N/A }
0N/A
0N/A /**
0N/A * Sets the title-position of the titled border.
0N/A * @param titlePosition the position for the border
0N/A */
0N/A public void setTitlePosition(int titlePosition) {
0N/A switch (titlePosition) {
0N/A case ABOVE_TOP:
0N/A case TOP:
0N/A case BELOW_TOP:
0N/A case ABOVE_BOTTOM:
0N/A case BOTTOM:
0N/A case BELOW_BOTTOM:
0N/A case DEFAULT_POSITION:
0N/A this.titlePosition = titlePosition;
0N/A break;
0N/A default:
0N/A throw new IllegalArgumentException(titlePosition +
0N/A " is not a valid title position.");
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the title-justification of the titled border.
0N/A * @param titleJustification the justification for the border
0N/A */
0N/A public void setTitleJustification(int titleJustification) {
0N/A switch (titleJustification) {
0N/A case DEFAULT_JUSTIFICATION:
0N/A case LEFT:
0N/A case CENTER:
0N/A case RIGHT:
0N/A case LEADING:
0N/A case TRAILING:
0N/A this.titleJustification = titleJustification;
0N/A break;
0N/A default:
0N/A throw new IllegalArgumentException(titleJustification +
0N/A " is not a valid title justification.");
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the title-font of the titled border.
0N/A * @param titleFont the font for the border title
0N/A */
0N/A public void setTitleFont(Font titleFont) {
0N/A this.titleFont = titleFont;
0N/A }
0N/A
0N/A /**
0N/A * Sets the title-color of the titled border.
0N/A * @param titleColor the color for the border title
0N/A */
0N/A public void setTitleColor(Color titleColor) {
0N/A this.titleColor = titleColor;
0N/A }
0N/A
0N/A /**
0N/A * Returns the minimum dimensions this border requires
0N/A * in order to fully display the border and title.
0N/A * @param c the component where this border will be drawn
0N/A * @return the {@code Dimension} object
0N/A */
0N/A public Dimension getMinimumSize(Component c) {
0N/A Insets insets = getBorderInsets(c);
0N/A Dimension minSize = new Dimension(insets.right+insets.left,
0N/A insets.top+insets.bottom);
0N/A String title = getTitle();
0N/A if ((title != null) && !title.isEmpty()) {
0N/A JLabel label = getLabel(c);
0N/A Dimension size = label.getPreferredSize();
0N/A
0N/A int position = getPosition();
0N/A if ((position != ABOVE_TOP) && (position != BELOW_BOTTOM)) {
0N/A minSize.width += size.width;
0N/A }
0N/A else if (minSize.width < size.width) {
0N/A minSize.width += size.width;
0N/A }
0N/A }
0N/A return minSize;
0N/A }
0N/A
0N/A /**
0N/A * Returns the baseline.
0N/A *
0N/A * @throws NullPointerException {@inheritDoc}
0N/A * @throws IllegalArgumentException {@inheritDoc}
0N/A * @see javax.swing.JComponent#getBaseline(int, int)
0N/A * @since 1.6
0N/A */
0N/A public int getBaseline(Component c, int width, int height) {
0N/A if (c == null) {
0N/A throw new NullPointerException("Must supply non-null component");
0N/A }
0N/A if (width < 0) {
0N/A throw new IllegalArgumentException("Width must be >= 0");
0N/A }
0N/A if (height < 0) {
0N/A throw new IllegalArgumentException("Height must be >= 0");
0N/A }
0N/A Border border = getBorder();
0N/A String title = getTitle();
0N/A if ((title != null) && !title.isEmpty()) {
0N/A int edge = (border instanceof TitledBorder) ? 0 : EDGE_SPACING;
0N/A JLabel label = getLabel(c);
0N/A Dimension size = label.getPreferredSize();
0N/A Insets insets = getBorderInsets(border, c, new Insets(0, 0, 0, 0));
0N/A
0N/A int baseline = label.getBaseline(size.width, size.height);
0N/A switch (getPosition()) {
0N/A case ABOVE_TOP:
0N/A return baseline;
0N/A case TOP:
0N/A insets.top = edge + (insets.top - size.height) / 2;
0N/A return (insets.top < edge)
0N/A ? baseline
0N/A : baseline + insets.top;
0N/A case BELOW_TOP:
0N/A return baseline + insets.top + edge;
0N/A case ABOVE_BOTTOM:
0N/A return baseline + height - size.height - insets.bottom - edge;
0N/A case BOTTOM:
0N/A insets.bottom = edge + (insets.bottom - size.height) / 2;
0N/A return (insets.bottom < edge)
0N/A ? baseline + height - size.height
0N/A : baseline + height - size.height + insets.bottom;
0N/A case BELOW_BOTTOM:
0N/A return baseline + height - size.height;
0N/A }
0N/A }
0N/A return -1;
0N/A }
0N/A
0N/A /**
0N/A * Returns an enum indicating how the baseline of the border
0N/A * changes as the size changes.
0N/A *
0N/A * @throws NullPointerException {@inheritDoc}
0N/A * @see javax.swing.JComponent#getBaseline(int, int)
0N/A * @since 1.6
0N/A */
0N/A public Component.BaselineResizeBehavior getBaselineResizeBehavior(
0N/A Component c) {
0N/A super.getBaselineResizeBehavior(c);
0N/A switch (getPosition()) {
0N/A case TitledBorder.ABOVE_TOP:
0N/A case TitledBorder.TOP:
0N/A case TitledBorder.BELOW_TOP:
0N/A return Component.BaselineResizeBehavior.CONSTANT_ASCENT;
0N/A case TitledBorder.ABOVE_BOTTOM:
0N/A case TitledBorder.BOTTOM:
0N/A case TitledBorder.BELOW_BOTTOM:
0N/A return JComponent.BaselineResizeBehavior.CONSTANT_DESCENT;
0N/A }
0N/A return Component.BaselineResizeBehavior.OTHER;
0N/A }
0N/A
0N/A private int getPosition() {
0N/A int position = getTitlePosition();
0N/A if (position != DEFAULT_POSITION) {
0N/A return position;
0N/A }
0N/A Object value = UIManager.get("TitledBorder.position");
0N/A if (value instanceof Integer) {
0N/A int i = (Integer) value;
0N/A if ((0 < i) && (i <= 6)) {
0N/A return i;
0N/A }
0N/A }
0N/A else if (value instanceof String) {
0N/A String s = (String) value;
0N/A if (s.equalsIgnoreCase("ABOVE_TOP")) {
0N/A return ABOVE_TOP;
0N/A }
0N/A if (s.equalsIgnoreCase("TOP")) {
0N/A return TOP;
0N/A }
0N/A if (s.equalsIgnoreCase("BELOW_TOP")) {
0N/A return BELOW_TOP;
0N/A }
0N/A if (s.equalsIgnoreCase("ABOVE_BOTTOM")) {
0N/A return ABOVE_BOTTOM;
0N/A }
0N/A if (s.equalsIgnoreCase("BOTTOM")) {
0N/A return BOTTOM;
0N/A }
0N/A if (s.equalsIgnoreCase("BELOW_BOTTOM")) {
0N/A return BELOW_BOTTOM;
0N/A }
0N/A }
0N/A return TOP;
0N/A }
0N/A
0N/A private int getJustification(Component c) {
0N/A int justification = getTitleJustification();
0N/A if ((justification == LEADING) || (justification == DEFAULT_JUSTIFICATION)) {
0N/A return c.getComponentOrientation().isLeftToRight() ? LEFT : RIGHT;
0N/A }
0N/A if (justification == TRAILING) {
0N/A return c.getComponentOrientation().isLeftToRight() ? RIGHT : LEFT;
0N/A }
0N/A return justification;
0N/A }
0N/A
0N/A protected Font getFont(Component c) {
0N/A Font font = getTitleFont();
0N/A if (font != null) {
0N/A return font;
0N/A }
0N/A font = UIManager.getFont("TitledBorder.font");
0N/A if (font != null) {
0N/A return font;
0N/A }
0N/A if (c != null) {
0N/A font = c.getFont();
0N/A if (font != null) {
0N/A return font;
0N/A }
0N/A }
0N/A return new Font(Font.DIALOG, Font.PLAIN, 12);
0N/A }
0N/A
0N/A private Color getColor(Component c) {
0N/A Color color = getTitleColor();
0N/A if (color != null) {
0N/A return color;
0N/A }
0N/A color = UIManager.getColor("TitledBorder.titleColor");
0N/A if (color != null) {
0N/A return color;
0N/A }
0N/A return (c != null)
0N/A ? c.getForeground()
0N/A : null;
0N/A }
0N/A
0N/A private JLabel getLabel(Component c) {
0N/A this.label.setText(getTitle());
0N/A this.label.setFont(getFont(c));
0N/A this.label.setForeground(getColor(c));
0N/A this.label.setComponentOrientation(c.getComponentOrientation());
0N/A this.label.setEnabled(c.isEnabled());
0N/A return this.label;
0N/A }
0N/A
0N/A private static Insets getBorderInsets(Border border, Component c, Insets insets) {
0N/A if (border == null) {
0N/A insets.set(0, 0, 0, 0);
0N/A }
0N/A else if (border instanceof AbstractBorder) {
0N/A AbstractBorder ab = (AbstractBorder) border;
0N/A insets = ab.getBorderInsets(c, insets);
0N/A }
0N/A else {
0N/A Insets i = border.getBorderInsets(c);
0N/A insets.set(i.top, i.left, i.bottom, i.right);
0N/A }
0N/A return insets;
0N/A }
0N/A}
0N/A