feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,199 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Component;
import java.io.Serializable;
/**
* A class that implements an empty border with no size.
* This provides a convenient base class from which other border
* classes can be easily derived.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author David Kloba
*/
@SuppressWarnings("serial")
public abstract class AbstractBorder implements Border, Serializable
{
/**
* This default implementation does no painting.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
}
/**
* This default implementation returns a new {@link Insets} object
* that is initialized by the {@link #getBorderInsets(Component,Insets)}
* method.
* By default the {@code top}, {@code left}, {@code bottom},
* and {@code right} fields are set to {@code 0}.
*
* @param c the component for which this border insets value applies
* @return a new {@link Insets} object
*/
public Insets getBorderInsets(Component c) {
return getBorderInsets(c, new Insets(0, 0, 0, 0));
}
/**
* Reinitializes the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
* @return the <code>insets</code> object
*/
public Insets getBorderInsets(Component c, Insets insets) {
insets.left = insets.top = insets.right = insets.bottom = 0;
return insets;
}
/**
* This default implementation returns false.
* @return false
*/
public boolean isBorderOpaque() { return false; }
/**
* This convenience method calls the static method.
* @param c the component for which this border is being computed
* @param x the x position of the border
* @param y the y position of the border
* @param width the width of the border
* @param height the height of the border
* @return a <code>Rectangle</code> containing the interior coordinates
*/
public Rectangle getInteriorRectangle(Component c, int x, int y, int width, int height) {
return getInteriorRectangle(c, this, x, y, width, height);
}
/**
* Returns a rectangle using the arguments minus the
* insets of the border. This is useful for determining the area
* that components should draw in that will not intersect the border.
* @param c the component for which this border is being computed
* @param b the <code>Border</code> object
* @param x the x position of the border
* @param y the y position of the border
* @param width the width of the border
* @param height the height of the border
* @return a <code>Rectangle</code> containing the interior coordinates
*/
public static Rectangle getInteriorRectangle(Component c, Border b, int x, int y, int width, int height) {
Insets insets;
if(b != null)
insets = b.getBorderInsets(c);
else
insets = new Insets(0, 0, 0, 0);
return new Rectangle(x + insets.left,
y + insets.top,
width - insets.right - insets.left,
height - insets.top - insets.bottom);
}
/**
* Returns the baseline. A return value less than 0 indicates the border
* does not have a reasonable baseline.
* <p>
* The default implementation returns -1. Subclasses that support
* baseline should override appropriately. If a value &gt;= 0 is
* returned, then the component has a valid baseline for any
* size &gt;= the minimum size and <code>getBaselineResizeBehavior</code>
* can be used to determine how the baseline changes with size.
*
* @param c <code>Component</code> baseline is being requested for
* @param width the width to get the baseline for
* @param height the height to get the baseline for
* @return the baseline or &lt; 0 indicating there is no reasonable
* baseline
* @throws IllegalArgumentException if width or height is &lt; 0
* @see java.awt.Component#getBaseline(int,int)
* @see java.awt.Component#getBaselineResizeBehavior()
* @since 1.6
*/
public int getBaseline(Component c, int width, int height) {
if (width < 0 || height < 0) {
throw new IllegalArgumentException(
"Width and height must be >= 0");
}
return -1;
}
/**
* Returns an enum indicating how the baseline of a component
* changes as the size changes. This method is primarily meant for
* layout managers and GUI builders.
* <p>
* The default implementation returns
* <code>BaselineResizeBehavior.OTHER</code>, subclasses that support
* baseline should override appropriately. Subclasses should
* never return <code>null</code>; if the baseline can not be
* calculated return <code>BaselineResizeBehavior.OTHER</code>. Callers
* should first ask for the baseline using
* <code>getBaseline</code> and if a value &gt;= 0 is returned use
* this method. It is acceptable for this method to return a
* value other than <code>BaselineResizeBehavior.OTHER</code> even if
* <code>getBaseline</code> returns a value less than 0.
*
* @param c <code>Component</code> to return baseline resize behavior for
* @return an enum indicating how the baseline changes as the border is
* resized
* @see java.awt.Component#getBaseline(int,int)
* @see java.awt.Component#getBaselineResizeBehavior()
* @since 1.6
*/
public Component.BaselineResizeBehavior getBaselineResizeBehavior(
Component c) {
if (c == null) {
throw new NullPointerException("Component must be non-null");
}
return Component.BaselineResizeBehavior.OTHER;
}
/*
* Convenience function for determining ComponentOrientation.
* Helps us avoid having Munge directives throughout the code.
*/
static boolean isLeftToRight( Component c ) {
return c.getComponentOrientation().isLeftToRight();
}
}

View File

@@ -0,0 +1,297 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Color;
import java.awt.Component;
import java.beans.ConstructorProperties;
/**
* A class which implements a simple two-line bevel border.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author David Kloba
*/
public class BevelBorder extends AbstractBorder
{
/** Raised bevel type. */
public static final int RAISED = 0;
/** Lowered bevel type. */
public static final int LOWERED = 1;
protected int bevelType;
protected Color highlightOuter;
protected Color highlightInner;
protected Color shadowInner;
protected Color shadowOuter;
/**
* Creates a bevel border with the specified type and whose
* colors will be derived from the background color of the
* component passed into the paintBorder method.
* @param bevelType the type of bevel for the border
*/
public BevelBorder(int bevelType) {
this.bevelType = bevelType;
}
/**
* Creates a bevel border with the specified type, highlight and
* shadow colors.
* @param bevelType the type of bevel for the border
* @param highlight the color to use for the bevel highlight
* @param shadow the color to use for the bevel shadow
*/
public BevelBorder(int bevelType, Color highlight, Color shadow) {
this(bevelType, highlight.brighter(), highlight, shadow, shadow.brighter());
}
/**
* Creates a bevel border with the specified type, highlight and
* shadow colors.
*
* @param bevelType the type of bevel for the border
* @param highlightOuterColor the color to use for the bevel outer highlight
* @param highlightInnerColor the color to use for the bevel inner highlight
* @param shadowOuterColor the color to use for the bevel outer shadow
* @param shadowInnerColor the color to use for the bevel inner shadow
*/
@ConstructorProperties({"bevelType", "highlightOuterColor", "highlightInnerColor", "shadowOuterColor", "shadowInnerColor"})
public BevelBorder(int bevelType, Color highlightOuterColor,
Color highlightInnerColor, Color shadowOuterColor,
Color shadowInnerColor) {
this(bevelType);
this.highlightOuter = highlightOuterColor;
this.highlightInner = highlightInnerColor;
this.shadowOuter = shadowOuterColor;
this.shadowInner = shadowInnerColor;
}
/**
* Paints the border for the specified component with the specified
* position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if (bevelType == RAISED) {
paintRaisedBevel(c, g, x, y, width, height);
} else if (bevelType == LOWERED) {
paintLoweredBevel(c, g, x, y, width, height);
}
}
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
public Insets getBorderInsets(Component c, Insets insets) {
insets.set(2, 2, 2, 2);
return insets;
}
/**
* Returns the outer highlight color of the bevel border
* when rendered on the specified component. If no highlight
* color was specified at instantiation, the highlight color
* is derived from the specified component's background color.
* @param c the component for which the highlight may be derived
* @since 1.3
*/
public Color getHighlightOuterColor(Component c) {
Color highlight = getHighlightOuterColor();
return highlight != null? highlight :
c.getBackground().brighter().brighter();
}
/**
* Returns the inner highlight color of the bevel border
* when rendered on the specified component. If no highlight
* color was specified at instantiation, the highlight color
* is derived from the specified component's background color.
* @param c the component for which the highlight may be derived
* @since 1.3
*/
public Color getHighlightInnerColor(Component c) {
Color highlight = getHighlightInnerColor();
return highlight != null? highlight :
c.getBackground().brighter();
}
/**
* Returns the inner shadow color of the bevel border
* when rendered on the specified component. If no shadow
* color was specified at instantiation, the shadow color
* is derived from the specified component's background color.
* @param c the component for which the shadow may be derived
* @since 1.3
*/
public Color getShadowInnerColor(Component c) {
Color shadow = getShadowInnerColor();
return shadow != null? shadow :
c.getBackground().darker();
}
/**
* Returns the outer shadow color of the bevel border
* when rendered on the specified component. If no shadow
* color was specified at instantiation, the shadow color
* is derived from the specified component's background color.
* @param c the component for which the shadow may be derived
* @since 1.3
*/
public Color getShadowOuterColor(Component c) {
Color shadow = getShadowOuterColor();
return shadow != null? shadow :
c.getBackground().darker().darker();
}
/**
* Returns the outer highlight color of the bevel border.
* Will return null if no highlight color was specified
* at instantiation.
* @since 1.3
*/
public Color getHighlightOuterColor() {
return highlightOuter;
}
/**
* Returns the inner highlight color of the bevel border.
* Will return null if no highlight color was specified
* at instantiation.
* @since 1.3
*/
public Color getHighlightInnerColor() {
return highlightInner;
}
/**
* Returns the inner shadow color of the bevel border.
* Will return null if no shadow color was specified
* at instantiation.
* @since 1.3
*/
public Color getShadowInnerColor() {
return shadowInner;
}
/**
* Returns the outer shadow color of the bevel border.
* Will return null if no shadow color was specified
* at instantiation.
* @since 1.3
*/
public Color getShadowOuterColor() {
return shadowOuter;
}
/**
* Returns the type of the bevel border.
*/
public int getBevelType() {
return bevelType;
}
/**
* Returns whether or not the border is opaque.
*/
public boolean isBorderOpaque() { return true; }
protected void paintRaisedBevel(Component c, Graphics g, int x, int y,
int width, int height) {
Color oldColor = g.getColor();
int h = height;
int w = width;
g.translate(x, y);
g.setColor(getHighlightOuterColor(c));
g.drawLine(0, 0, 0, h-2);
g.drawLine(1, 0, w-2, 0);
g.setColor(getHighlightInnerColor(c));
g.drawLine(1, 1, 1, h-3);
g.drawLine(2, 1, w-3, 1);
g.setColor(getShadowOuterColor(c));
g.drawLine(0, h-1, w-1, h-1);
g.drawLine(w-1, 0, w-1, h-2);
g.setColor(getShadowInnerColor(c));
g.drawLine(1, h-2, w-2, h-2);
g.drawLine(w-2, 1, w-2, h-3);
g.translate(-x, -y);
g.setColor(oldColor);
}
protected void paintLoweredBevel(Component c, Graphics g, int x, int y,
int width, int height) {
Color oldColor = g.getColor();
int h = height;
int w = width;
g.translate(x, y);
g.setColor(getShadowInnerColor(c));
g.drawLine(0, 0, 0, h-1);
g.drawLine(1, 0, w-1, 0);
g.setColor(getShadowOuterColor(c));
g.drawLine(1, 1, 1, h-2);
g.drawLine(2, 1, w-2, 1);
g.setColor(getHighlightOuterColor(c));
g.drawLine(1, h-1, w-1, h-1);
g.drawLine(w-1, 1, w-1, h-2);
g.setColor(getHighlightInnerColor(c));
g.drawLine(2, h-2, w-2, h-2);
g.drawLine(w-2, 2, w-2, h-3);
g.translate(-x, -y);
g.setColor(oldColor);
}
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Component;
/**
* Interface describing an object capable of rendering a border
* around the edges of a swing component.
* For examples of using borders see
* <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/border.htmll">How to Use Borders</a>,
* a section in <em>The Java Tutorial.</em>
* <p>
* In the Swing component set, borders supercede Insets as the
* mechanism for creating a (decorated or plain) area around the
* edge of a component.
* <p>
* Usage Notes:
* <ul>
* <li>Use EmptyBorder to create a plain border (this mechanism
* replaces its predecessor, <code>setInsets</code>).
* <li>Use CompoundBorder to nest multiple border objects, creating
* a single, combined border.
* <li>Border instances are designed to be shared. Rather than creating
* a new border object using one of border classes, use the
* BorderFactory methods, which produces a shared instance of the
* common border types.
* <li>Additional border styles include BevelBorder, SoftBevelBorder,
* EtchedBorder, LineBorder, TitledBorder, and MatteBorder.
* <li>To create a new border class, subclass AbstractBorder.
* </ul>
*
* @author David Kloba
* @author Amy Fowler
* @see javax.swing.BorderFactory
* @see EmptyBorder
* @see CompoundBorder
*/
public interface Border
{
/**
* Paints the border for the specified component with the specified
* position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
void paintBorder(Component c, Graphics g, int x, int y, int width, int height);
/**
* Returns the insets of the border.
* @param c the component for which this border insets value applies
*/
Insets getBorderInsets(Component c);
/**
* Returns whether or not the border is opaque. If the border
* is opaque, it is responsible for filling in it's own
* background when painting.
*/
boolean isBorderOpaque();
}

View File

@@ -0,0 +1,169 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Component;
import java.beans.ConstructorProperties;
/**
* A composite Border class used to compose two Border objects
* into a single border by nesting an inside Border object within
* the insets of an outside Border object.
*
* For example, this class may be used to add blank margin space
* to a component with an existing decorative border:
*
* <pre>
* Border border = comp.getBorder();
* Border margin = new EmptyBorder(10,10,10,10);
* comp.setBorder(new CompoundBorder(border, margin));
* </pre>
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author David Kloba
*/
@SuppressWarnings("serial")
public class CompoundBorder extends AbstractBorder {
protected Border outsideBorder;
protected Border insideBorder;
/**
* Creates a compound border with null outside and inside borders.
*/
public CompoundBorder() {
this.outsideBorder = null;
this.insideBorder = null;
}
/**
* Creates a compound border with the specified outside and
* inside borders. Either border may be null.
* @param outsideBorder the outside border
* @param insideBorder the inside border to be nested
*/
@ConstructorProperties({"outsideBorder", "insideBorder"})
public CompoundBorder(Border outsideBorder, Border insideBorder) {
this.outsideBorder = outsideBorder;
this.insideBorder = insideBorder;
}
/**
* Returns whether or not the compound border is opaque.
*
* @return {@code true} if the inside and outside borders
* are each either {@code null} or opaque;
* or {@code false} otherwise
*/
@Override
public boolean isBorderOpaque() {
return (outsideBorder == null || outsideBorder.isBorderOpaque()) &&
(insideBorder == null || insideBorder.isBorderOpaque());
}
/**
* 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.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Insets nextInsets;
int px, py, pw, ph;
px = x;
py = y;
pw = width;
ph = height;
if(outsideBorder != null) {
outsideBorder.paintBorder(c, g, px, py, pw, ph);
nextInsets = outsideBorder.getBorderInsets(c);
px += nextInsets.left;
py += nextInsets.top;
pw = pw - nextInsets.right - nextInsets.left;
ph = ph - nextInsets.bottom - nextInsets.top;
}
if(insideBorder != null)
insideBorder.paintBorder(c, g, px, py, pw, ph);
}
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
public Insets getBorderInsets(Component c, Insets insets) {
Insets nextInsets;
insets.top = insets.left = insets.right = insets.bottom = 0;
if(outsideBorder != null) {
nextInsets = outsideBorder.getBorderInsets(c);
insets.top += nextInsets.top;
insets.left += nextInsets.left;
insets.right += nextInsets.right;
insets.bottom += nextInsets.bottom;
}
if(insideBorder != null) {
nextInsets = insideBorder.getBorderInsets(c);
insets.top += nextInsets.top;
insets.left += nextInsets.left;
insets.right += nextInsets.right;
insets.bottom += nextInsets.bottom;
}
return insets;
}
/**
* Returns the outside border object.
*/
public Border getOutsideBorder() {
return outsideBorder;
}
/**
* Returns the inside border object.
*/
public Border getInsideBorder() {
return insideBorder;
}
}

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Component;
import java.io.Serializable;
import java.beans.ConstructorProperties;
/**
* A class which provides an empty, transparent border which
* takes up space but does no drawing.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author David Kloba
*/
@SuppressWarnings("serial")
public class EmptyBorder extends AbstractBorder implements Serializable
{
protected int left, right, top, bottom;
/**
* Creates an empty border with the specified insets.
* @param top the top inset of the border
* @param left the left inset of the border
* @param bottom the bottom inset of the border
* @param right the right inset of the border
*/
public EmptyBorder(int top, int left, int bottom, int right) {
this.top = top;
this.right = right;
this.bottom = bottom;
this.left = left;
}
/**
* Creates an empty border with the specified insets.
* @param borderInsets the insets of the border
*/
@ConstructorProperties({"borderInsets"})
public EmptyBorder(Insets borderInsets) {
this.top = borderInsets.top;
this.right = borderInsets.right;
this.bottom = borderInsets.bottom;
this.left = borderInsets.left;
}
/**
* Does no drawing by default.
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
}
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
public Insets getBorderInsets(Component c, Insets insets) {
insets.left = left;
insets.top = top;
insets.right = right;
insets.bottom = bottom;
return insets;
}
/**
* Returns the insets of the border.
* @since 1.3
*/
public Insets getBorderInsets() {
return new Insets(top, left, bottom, right);
}
/**
* Returns whether or not the border is opaque.
* Returns false by default.
*/
public boolean isBorderOpaque() { return false; }
}

View File

@@ -0,0 +1,205 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Color;
import java.awt.Component;
import java.beans.ConstructorProperties;
/**
* A class which implements a simple etched border which can
* either be etched-in or etched-out. If no highlight/shadow
* colors are initialized when the border is created, then
* these colors will be dynamically derived from the background
* color of the component argument passed into the paintBorder()
* method.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author David Kloba
* @author Amy Fowler
*/
public class EtchedBorder extends AbstractBorder
{
/** Raised etched type. */
public static final int RAISED = 0;
/** Lowered etched type. */
public static final int LOWERED = 1;
protected int etchType;
protected Color highlight;
protected Color shadow;
/**
* Creates a lowered etched border whose colors will be derived
* from the background color of the component passed into
* the paintBorder method.
*/
public EtchedBorder() {
this(LOWERED);
}
/**
* Creates an etched border with the specified etch-type
* whose colors will be derived
* from the background color of the component passed into
* the paintBorder method.
* @param etchType the type of etch to be drawn by the border
*/
public EtchedBorder(int etchType) {
this(etchType, null, null);
}
/**
* Creates a lowered etched border with the specified highlight and
* shadow colors.
* @param highlight the color to use for the etched highlight
* @param shadow the color to use for the etched shadow
*/
public EtchedBorder(Color highlight, Color shadow) {
this(LOWERED, highlight, shadow);
}
/**
* Creates an etched border with the specified etch-type,
* highlight and shadow colors.
* @param etchType the type of etch to be drawn by the border
* @param highlight the color to use for the etched highlight
* @param shadow the color to use for the etched shadow
*/
@ConstructorProperties({"etchType", "highlightColor", "shadowColor"})
public EtchedBorder(int etchType, Color highlight, Color shadow) {
this.etchType = etchType;
this.highlight = highlight;
this.shadow = shadow;
}
/**
* Paints the border for the specified component with the
* specified position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
int w = width;
int h = height;
g.translate(x, y);
g.setColor(etchType == LOWERED? getShadowColor(c) : getHighlightColor(c));
g.drawRect(0, 0, w-2, h-2);
g.setColor(etchType == LOWERED? getHighlightColor(c) : getShadowColor(c));
g.drawLine(1, h-3, 1, 1);
g.drawLine(1, 1, w-3, 1);
g.drawLine(0, h-1, w-1, h-1);
g.drawLine(w-1, h-1, w-1, 0);
g.translate(-x, -y);
}
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
public Insets getBorderInsets(Component c, Insets insets) {
insets.set(2, 2, 2, 2);
return insets;
}
/**
* Returns whether or not the border is opaque.
*/
public boolean isBorderOpaque() { return true; }
/**
* Returns which etch-type is set on the etched border.
*/
public int getEtchType() {
return etchType;
}
/**
* Returns the highlight color of the etched border
* when rendered on the specified component. If no highlight
* color was specified at instantiation, the highlight color
* is derived from the specified component's background color.
* @param c the component for which the highlight may be derived
* @since 1.3
*/
public Color getHighlightColor(Component c) {
return highlight != null? highlight :
c.getBackground().brighter();
}
/**
* Returns the highlight color of the etched border.
* Will return null if no highlight color was specified
* at instantiation.
* @since 1.3
*/
public Color getHighlightColor() {
return highlight;
}
/**
* Returns the shadow color of the etched border
* when rendered on the specified component. If no shadow
* color was specified at instantiation, the shadow color
* is derived from the specified component's background color.
* @param c the component for which the shadow may be derived
* @since 1.3
*/
public Color getShadowColor(Component c) {
return shadow != null? shadow : c.getBackground().darker();
}
/**
* Returns the shadow color of the etched border.
* Will return null if no shadow color was specified
* at instantiation.
* @since 1.3
*/
public Color getShadowColor() {
return shadow;
}
}

View File

@@ -0,0 +1,191 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
import java.beans.ConstructorProperties;
/**
* A class which implements a line border of arbitrary thickness
* and of a single color.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author David Kloba
*/
public class LineBorder extends AbstractBorder
{
private static Border blackLine;
private static Border grayLine;
protected int thickness;
protected Color lineColor;
protected boolean roundedCorners;
/** Convenience method for getting the Color.black LineBorder of thickness 1.
*/
public static Border createBlackLineBorder() {
if (blackLine == null) {
blackLine = new LineBorder(Color.black, 1);
}
return blackLine;
}
/** Convenience method for getting the Color.gray LineBorder of thickness 1.
*/
public static Border createGrayLineBorder() {
if (grayLine == null) {
grayLine = new LineBorder(Color.gray, 1);
}
return grayLine;
}
/**
* Creates a line border with the specified color and a
* thickness = 1.
* @param color the color for the border
*/
public LineBorder(Color color) {
this(color, 1, false);
}
/**
* Creates a line border with the specified color and thickness.
* @param color the color of the border
* @param thickness the thickness of the border
*/
public LineBorder(Color color, int thickness) {
this(color, thickness, false);
}
/**
* Creates a line border with the specified color, thickness,
* and corner shape.
* @param color the color of the border
* @param thickness the thickness of the border
* @param roundedCorners whether or not border corners should be round
* @since 1.3
*/
@ConstructorProperties({"lineColor", "thickness", "roundedCorners"})
public LineBorder(Color color, int thickness, boolean roundedCorners) {
lineColor = color;
this.thickness = thickness;
this.roundedCorners = roundedCorners;
}
/**
* Paints the border for the specified component with the
* specified position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if ((this.thickness > 0) && (g instanceof Graphics2D)) {
Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor);
Shape outer;
Shape inner;
int offs = this.thickness;
int size = offs + offs;
if (this.roundedCorners) {
float arc = .2f * offs;
outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
}
else {
outer = new Rectangle2D.Float(x, y, width, height);
inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
}
Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
path.append(outer, false);
path.append(inner, false);
g2d.fill(path);
g2d.setColor(oldColor);
}
}
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
public Insets getBorderInsets(Component c, Insets insets) {
insets.set(thickness, thickness, thickness, thickness);
return insets;
}
/**
* Returns the color of the border.
*/
public Color getLineColor() {
return lineColor;
}
/**
* Returns the thickness of the border.
*/
public int getThickness() {
return thickness;
}
/**
* Returns whether this border will be drawn with rounded corners.
* @since 1.3
*/
public boolean getRoundedCorners() {
return roundedCorners;
}
/**
* Returns whether or not the border is opaque.
*/
public boolean isBorderOpaque() {
return !roundedCorners;
}
}

View File

@@ -0,0 +1,222 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Component;
import java.awt.Color;
import javax.swing.Icon;
/**
* A class which provides a matte-like border of either a solid color
* or a tiled icon.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Amy Fowler
*/
@SuppressWarnings("serial")
public class MatteBorder extends EmptyBorder
{
protected Color color;
protected Icon tileIcon;
/**
* Creates a matte border with the specified insets and color.
* @param top the top inset of the border
* @param left the left inset of the border
* @param bottom the bottom inset of the border
* @param right the right inset of the border
* @param matteColor the color rendered for the border
*/
public MatteBorder(int top, int left, int bottom, int right, Color matteColor) {
super(top, left, bottom, right);
this.color = matteColor;
}
/**
* Creates a matte border with the specified insets and color.
* @param borderInsets the insets of the border
* @param matteColor the color rendered for the border
* @since 1.3
*/
public MatteBorder(Insets borderInsets, Color matteColor) {
super(borderInsets);
this.color = matteColor;
}
/**
* Creates a matte border with the specified insets and tile icon.
* @param top the top inset of the border
* @param left the left inset of the border
* @param bottom the bottom inset of the border
* @param right the right inset of the border
* @param tileIcon the icon to be used for tiling the border
*/
public MatteBorder(int top, int left, int bottom, int right, Icon tileIcon) {
super(top, left, bottom, right);
this.tileIcon = tileIcon;
}
/**
* Creates a matte border with the specified insets and tile icon.
* @param borderInsets the insets of the border
* @param tileIcon the icon to be used for tiling the border
* @since 1.3
*/
public MatteBorder(Insets borderInsets, Icon tileIcon) {
super(borderInsets);
this.tileIcon = tileIcon;
}
/**
* Creates a matte border with the specified tile icon. The
* insets will be calculated dynamically based on the size of
* the tile icon, where the top and bottom will be equal to the
* tile icon's height, and the left and right will be equal to
* the tile icon's width.
* @param tileIcon the icon to be used for tiling the border
*/
public MatteBorder(Icon tileIcon) {
this(-1,-1,-1,-1, tileIcon);
}
/**
* Paints the matte border.
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Insets insets = getBorderInsets(c);
Color oldColor = g.getColor();
g.translate(x, y);
// If the tileIcon failed loading, paint as gray.
if (tileIcon != null) {
color = (tileIcon.getIconWidth() == -1) ? Color.gray : null;
}
if (color != null) {
g.setColor(color);
g.fillRect(0, 0, width - insets.right, insets.top);
g.fillRect(0, insets.top, insets.left, height - insets.top);
g.fillRect(insets.left, height - insets.bottom, width - insets.left, insets.bottom);
g.fillRect(width - insets.right, 0, insets.right, height - insets.bottom);
} else if (tileIcon != null) {
int tileW = tileIcon.getIconWidth();
int tileH = tileIcon.getIconHeight();
paintEdge(c, g, 0, 0, width - insets.right, insets.top, tileW, tileH);
paintEdge(c, g, 0, insets.top, insets.left, height - insets.top, tileW, tileH);
paintEdge(c, g, insets.left, height - insets.bottom, width - insets.left, insets.bottom, tileW, tileH);
paintEdge(c, g, width - insets.right, 0, insets.right, height - insets.bottom, tileW, tileH);
}
g.translate(-x, -y);
g.setColor(oldColor);
}
private void paintEdge(Component c, Graphics g, int x, int y, int width, int height, int tileW, int tileH) {
g = g.create(x, y, width, height);
int sY = -(y % tileH);
for (x = -(x % tileW); x < width; x += tileW) {
for (y = sY; y < height; y += tileH) {
this.tileIcon.paintIcon(c, g, x, y);
}
}
g.dispose();
}
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
* @since 1.3
*/
public Insets getBorderInsets(Component c, Insets insets) {
return computeInsets(insets);
}
/**
* Returns the insets of the border.
* @since 1.3
*/
public Insets getBorderInsets() {
return computeInsets(new Insets(0,0,0,0));
}
/* should be protected once api changes area allowed */
private Insets computeInsets(Insets insets) {
if (tileIcon != null && top == -1 && bottom == -1 &&
left == -1 && right == -1) {
int w = tileIcon.getIconWidth();
int h = tileIcon.getIconHeight();
insets.top = h;
insets.right = w;
insets.bottom = h;
insets.left = w;
} else {
insets.left = left;
insets.top = top;
insets.right = right;
insets.bottom = bottom;
}
return insets;
}
/**
* Returns the color used for tiling the border or null
* if a tile icon is being used.
* @since 1.3
*/
public Color getMatteColor() {
return color;
}
/**
* Returns the icon used for tiling the border or null
* if a solid color is being used.
* @since 1.3
*/
public Icon getTileIcon() {
return tileIcon;
}
/**
* Returns whether or not the border is opaque.
*/
public boolean isBorderOpaque() {
// If a tileIcon is set, then it may contain transparent bits
return color != null;
}
}

View File

@@ -0,0 +1,165 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Color;
import java.awt.Component;
import java.beans.ConstructorProperties;
/**
* A class which implements a raised or lowered bevel with
* softened corners.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Amy Fowler
* @author Chester Rose
*/
public class SoftBevelBorder extends BevelBorder
{
/**
* Creates a bevel border with the specified type and whose
* colors will be derived from the background color of the
* component passed into the paintBorder method.
* @param bevelType the type of bevel for the border
*/
public SoftBevelBorder(int bevelType) {
super(bevelType);
}
/**
* Creates a bevel border with the specified type, highlight and
* shadow colors.
* @param bevelType the type of bevel for the border
* @param highlight the color to use for the bevel highlight
* @param shadow the color to use for the bevel shadow
*/
public SoftBevelBorder(int bevelType, Color highlight, Color shadow) {
super(bevelType, highlight, shadow);
}
/**
* Creates a bevel border with the specified type, highlight
* shadow colors.
* @param bevelType the type of bevel for the border
* @param highlightOuterColor the color to use for the bevel outer highlight
* @param highlightInnerColor the color to use for the bevel inner highlight
* @param shadowOuterColor the color to use for the bevel outer shadow
* @param shadowInnerColor the color to use for the bevel inner shadow
*/
@ConstructorProperties({"bevelType", "highlightOuterColor", "highlightInnerColor", "shadowOuterColor", "shadowInnerColor"})
public SoftBevelBorder(int bevelType, Color highlightOuterColor,
Color highlightInnerColor, Color shadowOuterColor,
Color shadowInnerColor) {
super(bevelType, highlightOuterColor, highlightInnerColor,
shadowOuterColor, shadowInnerColor);
}
/**
* Paints the border for the specified component with the specified
* position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Color oldColor = g.getColor();
g.translate(x, y);
if (bevelType == RAISED) {
g.setColor(getHighlightOuterColor(c));
g.drawLine(0, 0, width-2, 0);
g.drawLine(0, 0, 0, height-2);
g.drawLine(1, 1, 1, 1);
g.setColor(getHighlightInnerColor(c));
g.drawLine(2, 1, width-2, 1);
g.drawLine(1, 2, 1, height-2);
g.drawLine(2, 2, 2, 2);
g.drawLine(0, height-1, 0, height-2);
g.drawLine(width-1, 0, width-1, 0);
g.setColor(getShadowOuterColor(c));
g.drawLine(2, height-1, width-1, height-1);
g.drawLine(width-1, 2, width-1, height-1);
g.setColor(getShadowInnerColor(c));
g.drawLine(width-2, height-2, width-2, height-2);
} else if (bevelType == LOWERED) {
g.setColor(getShadowOuterColor(c));
g.drawLine(0, 0, width-2, 0);
g.drawLine(0, 0, 0, height-2);
g.drawLine(1, 1, 1, 1);
g.setColor(getShadowInnerColor(c));
g.drawLine(2, 1, width-2, 1);
g.drawLine(1, 2, 1, height-2);
g.drawLine(2, 2, 2, 2);
g.drawLine(0, height-1, 0, height-2);
g.drawLine(width-1, 0, width-1, 0);
g.setColor(getHighlightOuterColor(c));
g.drawLine(2, height-1, width-1, height-1);
g.drawLine(width-1, 2, width-1, height-1);
g.setColor(getHighlightInnerColor(c));
g.drawLine(width-2, height-2, width-2, height-2);
}
g.translate(-x, -y);
g.setColor(oldColor);
}
/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
public Insets getBorderInsets(Component c, Insets insets) {
insets.set(3, 3, 3, 3);
return insets;
}
/**
* Returns whether or not the border is opaque.
*/
public boolean isBorderOpaque() { return false; }
}

View File

@@ -0,0 +1,164 @@
/*
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.swing.border;
import java.awt.BasicStroke;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.geom.Rectangle2D;
import java.beans.ConstructorProperties;
/**
* A class which implements a border of an arbitrary stroke.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI
* between applications running the same version of Swing.
* As of 1.4, support for long term storage of all JavaBeans&trade;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Sergey A. Malenkov
*
* @since 1.7
*/
public class StrokeBorder extends AbstractBorder {
private final BasicStroke stroke;
private final Paint paint;
/**
* Creates a border of the specified {@code stroke}.
* The component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*/
public StrokeBorder(BasicStroke stroke) {
this(stroke, null);
}
/**
* Creates a border of the specified {@code stroke} and {@code paint}.
* If the specified {@code paint} is {@code null},
* the component's foreground color will be used to render the border.
*
* @param stroke the {@link BasicStroke} object used to stroke a shape
* @param paint the {@link Paint} object used to generate a color
*
* @throws NullPointerException if the specified {@code stroke} is {@code null}
*/
@ConstructorProperties({ "stroke", "paint" })
public StrokeBorder(BasicStroke stroke, Paint paint) {
if (stroke == null) {
throw new NullPointerException("border's stroke");
}
this.stroke = stroke;
this.paint = paint;
}
/**
* Paints the border for the specified component
* with the specified position and size.
* If the border was not specified with a {@link Paint} object,
* the component's foreground color will be used to render the border.
* If the component's foreground color is not available,
* the default color of the {@link Graphics} object will be used.
*
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*
* @throws NullPointerException if the specified {@code g} is {@code null}
*/
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
float size = this.stroke.getLineWidth();
if (size > 0.0f) {
g = g.create();
if (g instanceof Graphics2D) {
Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(this.stroke);
g2d.setPaint(this.paint != null ? this.paint : c == null ? null : c.getForeground());
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2d.draw(new Rectangle2D.Float(x + size / 2, y + size / 2, width - size, height - size));
}
g.dispose();
}
}
/**
* Reinitializes the {@code insets} parameter
* with this border's current insets.
* Every inset is the smallest (closest to negative infinity) integer value
* that is greater than or equal to the line width of the stroke
* that is used to paint the border.
*
* @param c the component for which this border insets value applies
* @param insets the {@code Insets} object to be reinitialized
* @return the reinitialized {@code insets} parameter
*
* @throws NullPointerException if the specified {@code insets} is {@code null}
*
* @see Math#ceil
*/
@Override
public Insets getBorderInsets(Component c, Insets insets) {
int size = (int) Math.ceil(this.stroke.getLineWidth());
insets.set(size, size, size, size);
return insets;
}
/**
* Returns the {@link BasicStroke} object used to stroke a shape
* during the border rendering.
*
* @return the {@link BasicStroke} object
*/
public BasicStroke getStroke() {
return this.stroke;
}
/**
* Returns the {@link Paint} object used to generate a color
* during the border rendering.
*
* @return the {@link Paint} object or {@code null}
* if the {@code paint} parameter is not set
*/
public Paint getPaint() {
return this.paint;
}
}

View File

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