Path: blob/master/src/java.desktop/share/classes/javax/swing/BorderFactory.java
41153 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package javax.swing;2526import java.awt.BasicStroke;27import java.awt.Color;28import java.awt.Font;29import java.awt.Paint;30import javax.swing.border.*;3132/**33* Factory class for vending standard <code>Border</code> objects. Wherever34* possible, this factory will hand out references to shared35* <code>Border</code> instances.36* For further information and examples see37* <a href="https://docs.oracle.com/javase/tutorial/uiswing/components/border.html">How38to Use Borders</a>,39* a section in <em>The Java Tutorial</em>.40*41* @author David Kloba42* @since 1.243*/44public class BorderFactory45{4647/** Don't let anyone instantiate this class */48private BorderFactory() {49}505152//// LineBorder ///////////////////////////////////////////////////////////////53/**54* Creates a line border with the specified color.55*56* @param color a <code>Color</code> to use for the line57* @return the <code>Border</code> object58*/59public static Border createLineBorder(Color color) {60return new LineBorder(color, 1);61}6263/**64* Creates a line border with the specified color65* and width. The width applies to all four sides of the66* border. To specify widths individually for the top,67* bottom, left, and right, use68* {@link #createMatteBorder(int,int,int,int,Color)}.69*70* @param color a <code>Color</code> to use for the line71* @param thickness an integer specifying the width in pixels72* @return the <code>Border</code> object73*/74public static Border createLineBorder(Color color, int thickness) {75return new LineBorder(color, thickness);76}7778/**79* Creates a line border with the specified color, thickness, and corner shape.80*81* @param color the color of the border82* @param thickness the thickness of the border83* @param rounded whether or not border corners should be round84* @return the {@code Border} object85*86* @see LineBorder#LineBorder(Color, int, boolean)87* @since 1.788*/89public static Border createLineBorder(Color color, int thickness, boolean rounded) {90return new LineBorder(color, thickness, rounded);91}9293//// BevelBorder /////////////////////////////////////////////////////////////94///////////////////////////////////////////////////////////////////////////////95static final Border sharedRaisedBevel = new BevelBorder(BevelBorder.RAISED);96static final Border sharedLoweredBevel = new BevelBorder(BevelBorder.LOWERED);9798/**99* Creates a border with a raised beveled edge, using100* brighter shades of the component's current background color101* for highlighting, and darker shading for shadows.102* (In a raised border, highlights are on top and shadows103* are underneath.)104*105* @return the <code>Border</code> object106*/107public static Border createRaisedBevelBorder() {108return createSharedBevel(BevelBorder.RAISED);109}110111/**112* Creates a border with a lowered beveled edge, using113* brighter shades of the component's current background color114* for highlighting, and darker shading for shadows.115* (In a lowered border, shadows are on top and highlights116* are underneath.)117*118* @return the <code>Border</code> object119*/120public static Border createLoweredBevelBorder() {121return createSharedBevel(BevelBorder.LOWERED);122}123124/**125* Creates a beveled border of the specified type, using126* brighter shades of the component's current background color127* for highlighting, and darker shading for shadows.128* (In a lowered border, shadows are on top and highlights129* are underneath.)130*131* @param type an integer specifying either132* <code>BevelBorder.LOWERED</code> or133* <code>BevelBorder.RAISED</code>134* @return the <code>Border</code> object135*/136public static Border createBevelBorder(int type) {137return createSharedBevel(type);138}139140/**141* Creates a beveled border of the specified type, using142* the specified highlighting and shadowing. The outer143* edge of the highlighted area uses a brighter shade of144* the highlight color. The inner edge of the shadow area145* uses a brighter shade of the shadow color.146*147* @param type an integer specifying either148* <code>BevelBorder.LOWERED</code> or149* <code>BevelBorder.RAISED</code>150* @param highlight a <code>Color</code> object for highlights151* @param shadow a <code>Color</code> object for shadows152* @return the <code>Border</code> object153*/154public static Border createBevelBorder(int type, Color highlight, Color shadow) {155return new BevelBorder(type, highlight, shadow);156}157158/**159* Creates a beveled border of the specified type, using160* the specified colors for the inner and outer highlight161* and shadow areas.162*163* @param type an integer specifying either164* <code>BevelBorder.LOWERED</code> or165* <code>BevelBorder.RAISED</code>166* @param highlightOuter a <code>Color</code> object for the167* outer edge of the highlight area168* @param highlightInner a <code>Color</code> object for the169* inner edge of the highlight area170* @param shadowOuter a <code>Color</code> object for the171* outer edge of the shadow area172* @param shadowInner a <code>Color</code> object for the173* inner edge of the shadow area174* @return the <code>Border</code> object175*/176public static Border createBevelBorder(int type,177Color highlightOuter, Color highlightInner,178Color shadowOuter, Color shadowInner) {179return new BevelBorder(type, highlightOuter, highlightInner,180shadowOuter, shadowInner);181}182183static Border createSharedBevel(int type) {184if(type == BevelBorder.RAISED) {185return sharedRaisedBevel;186} else if(type == BevelBorder.LOWERED) {187return sharedLoweredBevel;188}189return null;190}191192//// SoftBevelBorder ///////////////////////////////////////////////////////////193////////////////////////////////////////////////////////////////////////////////194195private static Border sharedSoftRaisedBevel;196private static Border sharedSoftLoweredBevel;197198/**199* Creates a beveled border with a raised edge and softened corners,200* using brighter shades of the component's current background color201* for highlighting, and darker shading for shadows.202* In a raised border, highlights are on top and shadows are underneath.203*204* @return the {@code Border} object205*206* @since 1.7207*/208public static Border createRaisedSoftBevelBorder() {209if (sharedSoftRaisedBevel == null) {210sharedSoftRaisedBevel = new SoftBevelBorder(BevelBorder.RAISED);211}212return sharedSoftRaisedBevel;213}214215/**216* Creates a beveled border with a lowered edge and softened corners,217* using brighter shades of the component's current background color218* for highlighting, and darker shading for shadows.219* In a lowered border, shadows are on top and highlights are underneath.220*221* @return the {@code Border} object222*223* @since 1.7224*/225public static Border createLoweredSoftBevelBorder() {226if (sharedSoftLoweredBevel == null) {227sharedSoftLoweredBevel = new SoftBevelBorder(BevelBorder.LOWERED);228}229return sharedSoftLoweredBevel;230}231232/**233* Creates a beveled border of the specified type with softened corners,234* using brighter shades of the component's current background color235* for highlighting, and darker shading for shadows.236* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.237*238* @param type a type of a bevel239* @return the {@code Border} object or {@code null}240* if the specified type is not valid241*242* @see BevelBorder#BevelBorder(int)243* @since 1.7244*/245public static Border createSoftBevelBorder(int type) {246if (type == BevelBorder.RAISED) {247return createRaisedSoftBevelBorder();248}249if (type == BevelBorder.LOWERED) {250return createLoweredSoftBevelBorder();251}252return null;253}254255/**256* Creates a beveled border of the specified type with softened corners,257* using the specified highlighting and shadowing.258* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.259* The outer edge of the highlight area uses260* a brighter shade of the {@code highlight} color.261* The inner edge of the shadow area uses262* a brighter shade of the {@code shadow} color.263*264* @param type a type of a bevel265* @param highlight a basic color of the highlight area266* @param shadow a basic color of the shadow area267* @return the {@code Border} object268*269* @see BevelBorder#BevelBorder(int, Color, Color)270* @since 1.7271*/272public static Border createSoftBevelBorder(int type, Color highlight, Color shadow) {273return new SoftBevelBorder(type, highlight, shadow);274}275276/**277* Creates a beveled border of the specified type with softened corners,278* using the specified colors for the inner and outer edges279* of the highlight and the shadow areas.280* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.281* Note: The shadow inner and outer colors are switched282* for a lowered bevel border.283*284* @param type a type of a bevel285* @param highlightOuter a color of the outer edge of the highlight area286* @param highlightInner a color of the inner edge of the highlight area287* @param shadowOuter a color of the outer edge of the shadow area288* @param shadowInner a color of the inner edge of the shadow area289* @return the {@code Border} object290*291* @see BevelBorder#BevelBorder(int, Color, Color, Color, Color)292* @since 1.7293*/294public static Border createSoftBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner) {295return new SoftBevelBorder(type, highlightOuter, highlightInner, shadowOuter, shadowInner);296}297298//// EtchedBorder ///////////////////////////////////////////////////////////299300static final Border sharedEtchedBorder = new EtchedBorder();301private static Border sharedRaisedEtchedBorder;302303/**304* Creates a border with an "etched" look using305* the component's current background color for306* highlighting and shading.307*308* @return the <code>Border</code> object309*/310public static Border createEtchedBorder() {311return sharedEtchedBorder;312}313314/**315* Creates a border with an "etched" look using316* the specified highlighting and shading colors.317*318* @param highlight a <code>Color</code> object for the border highlights319* @param shadow a <code>Color</code> object for the border shadows320* @return the <code>Border</code> object321*/322public static Border createEtchedBorder(Color highlight, Color shadow) {323return new EtchedBorder(highlight, shadow);324}325326/**327* Creates a border with an "etched" look using328* the component's current background color for329* highlighting and shading.330*331* @param type one of <code>EtchedBorder.RAISED</code>, or332* <code>EtchedBorder.LOWERED</code>333* @return the <code>Border</code> object334* @exception IllegalArgumentException if type is not either335* <code>EtchedBorder.RAISED</code> or336* <code>EtchedBorder.LOWERED</code>337* @since 1.3338*/339public static Border createEtchedBorder(int type) {340switch (type) {341case EtchedBorder.RAISED:342if (sharedRaisedEtchedBorder == null) {343sharedRaisedEtchedBorder = new EtchedBorder344(EtchedBorder.RAISED);345}346return sharedRaisedEtchedBorder;347case EtchedBorder.LOWERED:348return sharedEtchedBorder;349default:350throw new IllegalArgumentException("type must be one of EtchedBorder.RAISED or EtchedBorder.LOWERED");351}352}353354/**355* Creates a border with an "etched" look using356* the specified highlighting and shading colors.357*358* @param type one of <code>EtchedBorder.RAISED</code>, or359* <code>EtchedBorder.LOWERED</code>360* @param highlight a <code>Color</code> object for the border highlights361* @param shadow a <code>Color</code> object for the border shadows362* @return the <code>Border</code> object363* @since 1.3364*/365public static Border createEtchedBorder(int type, Color highlight,366Color shadow) {367return new EtchedBorder(type, highlight, shadow);368}369370//// TitledBorder ////////////////////////////////////////////////////////////371/**372* Creates a new titled border with the specified title,373* the default border type (determined by the current look and feel),374* the default text position (determined by the current look and feel),375* the default justification (leading), and the default376* font and text color (determined by the current look and feel).377*378* @param title a <code>String</code> containing the text of the title379* @return the <code>TitledBorder</code> object380*/381public static TitledBorder createTitledBorder(String title) {382return new TitledBorder(title);383}384385/**386* Creates a new titled border with an empty title,387* the specified border object,388* the default text position (determined by the current look and feel),389* the default justification (leading), and the default390* font and text color (determined by the current look and feel).391*392* @param border the <code>Border</code> object to add the title to; if393* <code>null</code> the <code>Border</code> is determined394* by the current look and feel.395* @return the <code>TitledBorder</code> object396*/397public static TitledBorder createTitledBorder(Border border) {398return new TitledBorder(border);399}400401/**402* Adds a title to an existing border,403* with default positioning (determined by the current look and feel),404* default justification (leading) and the default405* font and text color (determined by the current look and feel).406*407* @param border the <code>Border</code> object to add the title to408* @param title a <code>String</code> containing the text of the title409* @return the <code>TitledBorder</code> object410*/411public static TitledBorder createTitledBorder(Border border,412String title) {413return new TitledBorder(border, title);414}415416/**417* Adds a title to an existing border, with the specified418* positioning and using the default419* font and text color (determined by the current look and feel).420*421* @param border the <code>Border</code> object to add the title to422* @param title a <code>String</code> containing the text of the title423* @param titleJustification an integer specifying the justification424* of the title -- one of the following:425*<ul>426*<li><code>TitledBorder.LEFT</code>427*<li><code>TitledBorder.CENTER</code>428*<li><code>TitledBorder.RIGHT</code>429*<li><code>TitledBorder.LEADING</code>430*<li><code>TitledBorder.TRAILING</code>431*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading)432*</ul>433* @param titlePosition an integer specifying the vertical position of434* the text in relation to the border -- one of the following:435*<ul>436*<li><code> TitledBorder.ABOVE_TOP</code>437*<li><code>TitledBorder.TOP</code> (sitting on the top line)438*<li><code>TitledBorder.BELOW_TOP</code>439*<li><code>TitledBorder.ABOVE_BOTTOM</code>440*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)441*<li><code>TitledBorder.BELOW_BOTTOM</code>442*<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position443* is determined by the current look and feel)444*</ul>445* @return the <code>TitledBorder</code> object446*/447public static TitledBorder createTitledBorder(Border border,448String title,449int titleJustification,450int titlePosition) {451return new TitledBorder(border, title, titleJustification,452titlePosition);453}454455/**456* Adds a title to an existing border, with the specified457* positioning and font, and using the default text color458* (determined by the current look and feel).459*460* @param border the <code>Border</code> object to add the title to461* @param title a <code>String</code> containing the text of the title462* @param titleJustification an integer specifying the justification463* of the title -- one of the following:464*<ul>465*<li><code>TitledBorder.LEFT</code>466*<li><code>TitledBorder.CENTER</code>467*<li><code>TitledBorder.RIGHT</code>468*<li><code>TitledBorder.LEADING</code>469*<li><code>TitledBorder.TRAILING</code>470*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading)471*</ul>472* @param titlePosition an integer specifying the vertical position of473* the text in relation to the border -- one of the following:474*<ul>475*<li><code> TitledBorder.ABOVE_TOP</code>476*<li><code>TitledBorder.TOP</code> (sitting on the top line)477*<li><code>TitledBorder.BELOW_TOP</code>478*<li><code>TitledBorder.ABOVE_BOTTOM</code>479*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)480*<li><code>TitledBorder.BELOW_BOTTOM</code>481*<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position482* is determined by the current look and feel)483*</ul>484* @param titleFont a Font object specifying the title font485* @return the TitledBorder object486*/487public static TitledBorder createTitledBorder(Border border,488String title,489int titleJustification,490int titlePosition,491Font titleFont) {492return new TitledBorder(border, title, titleJustification,493titlePosition, titleFont);494}495496/**497* Adds a title to an existing border, with the specified498* positioning, font and color.499*500* @param border the <code>Border</code> object to add the title to501* @param title a <code>String</code> containing the text of the title502* @param titleJustification an integer specifying the justification503* of the title -- one of the following:504*<ul>505*<li><code>TitledBorder.LEFT</code>506*<li><code>TitledBorder.CENTER</code>507*<li><code>TitledBorder.RIGHT</code>508*<li><code>TitledBorder.LEADING</code>509*<li><code>TitledBorder.TRAILING</code>510*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading)511*</ul>512* @param titlePosition an integer specifying the vertical position of513* the text in relation to the border -- one of the following:514*<ul>515*<li><code> TitledBorder.ABOVE_TOP</code>516*<li><code>TitledBorder.TOP</code> (sitting on the top line)517*<li><code>TitledBorder.BELOW_TOP</code>518*<li><code>TitledBorder.ABOVE_BOTTOM</code>519*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)520*<li><code>TitledBorder.BELOW_BOTTOM</code>521*<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position522* is determined by the current look and feel)523*</ul>524* @param titleFont a <code>Font</code> object specifying the title font525* @param titleColor a <code>Color</code> object specifying the title color526* @return the <code>TitledBorder</code> object527*/528public static TitledBorder createTitledBorder(Border border,529String title,530int titleJustification,531int titlePosition,532Font titleFont,533Color titleColor) {534return new TitledBorder(border, title, titleJustification,535titlePosition, titleFont, titleColor);536}537//// EmptyBorder ///////////////////////////////////////////////////////////538static final Border emptyBorder = new EmptyBorder(0, 0, 0, 0);539540/**541* Creates an empty border that takes up no space. (The width542* of the top, bottom, left, and right sides are all zero.)543*544* @return the <code>Border</code> object545*/546public static Border createEmptyBorder() {547return emptyBorder;548}549550/**551* Creates an empty border that takes up space but which does552* no drawing, specifying the width of the top, left, bottom, and553* right sides.554*555* @param top an integer specifying the width of the top,556* in pixels557* @param left an integer specifying the width of the left side,558* in pixels559* @param bottom an integer specifying the width of the bottom,560* in pixels561* @param right an integer specifying the width of the right side,562* in pixels563* @return the <code>Border</code> object564*/565public static Border createEmptyBorder(int top, int left,566int bottom, int right) {567return new EmptyBorder(top, left, bottom, right);568}569570//// CompoundBorder ////////////////////////////////////////////////////////571/**572* Creates a compound border with a <code>null</code> inside edge and a573* <code>null</code> outside edge.574*575* @return the <code>CompoundBorder</code> object576*/577public static CompoundBorder createCompoundBorder() {578return new CompoundBorder();579}580581/**582* Creates a compound border specifying the border objects to use583* for the outside and inside edges.584*585* @param outsideBorder a <code>Border</code> object for the outer586* edge of the compound border587* @param insideBorder a <code>Border</code> object for the inner588* edge of the compound border589* @return the <code>CompoundBorder</code> object590*/591public static CompoundBorder createCompoundBorder(Border outsideBorder,592Border insideBorder) {593return new CompoundBorder(outsideBorder, insideBorder);594}595596//// MatteBorder ////////////////////////////////////////////////////////597/**598* Creates a matte-look border using a solid color. (The difference between599* this border and a line border is that you can specify the individual600* border dimensions.)601*602* @param top an integer specifying the width of the top,603* in pixels604* @param left an integer specifying the width of the left side,605* in pixels606* @param bottom an integer specifying the width of the right side,607* in pixels608* @param right an integer specifying the width of the bottom,609* in pixels610* @param color a <code>Color</code> to use for the border611* @return the <code>MatteBorder</code> object612*/613public static MatteBorder createMatteBorder(int top, int left, int bottom, int right,614Color color) {615return new MatteBorder(top, left, bottom, right, color);616}617618/**619* Creates a matte-look border that consists of multiple tiles of a620* specified icon. Multiple copies of the icon are placed side-by-side621* to fill up the border area.622* <p>623* Note:<br>624* If the icon doesn't load, the border area is painted gray.625*626* @param top an integer specifying the width of the top,627* in pixels628* @param left an integer specifying the width of the left side,629* in pixels630* @param bottom an integer specifying the width of the right side,631* in pixels632* @param right an integer specifying the width of the bottom,633* in pixels634* @param tileIcon the <code>Icon</code> object used for the border tiles635* @return the <code>MatteBorder</code> object636*/637public static MatteBorder createMatteBorder(int top, int left, int bottom, int right,638Icon tileIcon) {639return new MatteBorder(top, left, bottom, right, tileIcon);640}641642//// StrokeBorder //////////////////////////////////////////////////////////////643////////////////////////////////////////////////////////////////////////////////644645/**646* Creates a border of the specified {@code stroke}.647* The component's foreground color will be used to render the border.648*649* @param stroke the {@link BasicStroke} object used to stroke a shape650* @return the {@code Border} object651*652* @throws NullPointerException if the specified {@code stroke} is {@code null}653*654* @since 1.7655*/656public static Border createStrokeBorder(BasicStroke stroke) {657return new StrokeBorder(stroke);658}659660/**661* Creates a border of the specified {@code stroke} and {@code paint}.662* If the specified {@code paint} is {@code null},663* the component's foreground color will be used to render the border.664*665* @param stroke the {@link BasicStroke} object used to stroke a shape666* @param paint the {@link Paint} object used to generate a color667* @return the {@code Border} object668*669* @throws NullPointerException if the specified {@code stroke} is {@code null}670*671* @since 1.7672*/673public static Border createStrokeBorder(BasicStroke stroke, Paint paint) {674return new StrokeBorder(stroke, paint);675}676677//// DashedBorder //////////////////////////////////////////////////////////////678////////////////////////////////////////////////////////////////////////////////679680private static Border sharedDashedBorder;681682/**683* Creates a dashed border of the specified {@code paint}.684* If the specified {@code paint} is {@code null},685* the component's foreground color will be used to render the border.686* The width of a dash line is equal to {@code 1}.687* The relative length of a dash line and688* the relative spacing between dash lines are equal to {@code 1}.689* A dash line is not rounded.690*691* @param paint the {@link Paint} object used to generate a color692* @return the {@code Border} object693*694* @since 1.7695*/696public static Border createDashedBorder(Paint paint) {697return createDashedBorder(paint, 1.0f, 1.0f, 1.0f, false);698}699700/**701* Creates a dashed border of the specified {@code paint},702* relative {@code length}, and relative {@code spacing}.703* If the specified {@code paint} is {@code null},704* the component's foreground color will be used to render the border.705* The width of a dash line is equal to {@code 1}.706* A dash line is not rounded.707*708* @param paint the {@link Paint} object used to generate a color709* @param length the relative length of a dash line710* @param spacing the relative spacing between dash lines711* @return the {@code Border} object712*713* @throws IllegalArgumentException if the specified {@code length} is less than {@code 1}, or714* if the specified {@code spacing} is less than {@code 0}715* @since 1.7716*/717public static Border createDashedBorder(Paint paint, float length, float spacing) {718return createDashedBorder(paint, 1.0f, length, spacing, false);719}720721/**722* Creates a dashed border of the specified {@code paint}, {@code thickness},723* line shape, relative {@code length}, and relative {@code spacing}.724* If the specified {@code paint} is {@code null},725* the component's foreground color will be used to render the border.726*727* @param paint the {@link Paint} object used to generate a color728* @param thickness the width of a dash line729* @param length the relative length of a dash line730* @param spacing the relative spacing between dash lines731* @param rounded whether or not line ends should be round732* @return the {@code Border} object733*734* @throws IllegalArgumentException if the specified {@code thickness} is less than {@code 1}, or735* if the specified {@code length} is less than {@code 1}, or736* if the specified {@code spacing} is less than {@code 0}737* @since 1.7738*/739public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded) {740boolean shared = !rounded && (paint == null) && (thickness == 1.0f) && (length == 1.0f) && (spacing == 1.0f);741if (shared && (sharedDashedBorder != null)) {742return sharedDashedBorder;743}744if (thickness < 1.0f) {745throw new IllegalArgumentException("thickness is less than 1");746}747if (length < 1.0f) {748throw new IllegalArgumentException("length is less than 1");749}750if (spacing < 0.0f) {751throw new IllegalArgumentException("spacing is less than 0");752}753int cap = rounded ? BasicStroke.CAP_ROUND : BasicStroke.CAP_SQUARE;754int join = rounded ? BasicStroke.JOIN_ROUND : BasicStroke.JOIN_MITER;755float[] array = { thickness * (length - 1.0f), thickness * (spacing + 1.0f) };756Border border = createStrokeBorder(new BasicStroke(thickness, cap, join, thickness * 2.0f, array, 0.0f), paint);757if (shared) {758sharedDashedBorder = border;759}760return border;761}762}763764765