Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/swing/BorderFactory.java
38829 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.htmll">How38to Use Borders</a>,39* a section in <em>The Java Tutorial</em>.40*41* @author David Kloba42*/43public class BorderFactory44{4546/** Don't let anyone instantiate this class */47private BorderFactory() {48}495051//// LineBorder ///////////////////////////////////////////////////////////////52/**53* Creates a line border withe the specified color.54*55* @param color a <code>Color</code> to use for the line56* @return the <code>Border</code> object57*/58public static Border createLineBorder(Color color) {59return new LineBorder(color, 1);60}6162/**63* Creates a line border with the specified color64* and width. The width applies to all four sides of the65* border. To specify widths individually for the top,66* bottom, left, and right, use67* {@link #createMatteBorder(int,int,int,int,Color)}.68*69* @param color a <code>Color</code> to use for the line70* @param thickness an integer specifying the width in pixels71* @return the <code>Border</code> object72*/73public static Border createLineBorder(Color color, int thickness) {74return new LineBorder(color, thickness);75}7677/**78* Creates a line border with the specified color, thickness, and corner shape.79*80* @param color the color of the border81* @param thickness the thickness of the border82* @param rounded whether or not border corners should be round83* @return the {@code Border} object84*85* @see LineBorder#LineBorder(Color, int, boolean)86* @since 1.787*/88public static Border createLineBorder(Color color, int thickness, boolean rounded) {89return new LineBorder(color, thickness, rounded);90}9192//// BevelBorder /////////////////////////////////////////////////////////////93///////////////////////////////////////////////////////////////////////////////94static final Border sharedRaisedBevel = new BevelBorder(BevelBorder.RAISED);95static final Border sharedLoweredBevel = new BevelBorder(BevelBorder.LOWERED);9697/**98* Creates a border with a raised beveled edge, using99* brighter shades of the component's current background color100* for highlighting, and darker shading for shadows.101* (In a raised border, highlights are on top and shadows102* are underneath.)103*104* @return the <code>Border</code> object105*/106public static Border createRaisedBevelBorder() {107return createSharedBevel(BevelBorder.RAISED);108}109110/**111* Creates a border with a lowered beveled edge, using112* brighter shades of the component's current background color113* for highlighting, and darker shading for shadows.114* (In a lowered border, shadows are on top and highlights115* are underneath.)116*117* @return the <code>Border</code> object118*/119public static Border createLoweredBevelBorder() {120return createSharedBevel(BevelBorder.LOWERED);121}122123/**124* Creates a beveled border of the specified type, using125* brighter shades of the component's current background color126* for highlighting, and darker shading for shadows.127* (In a lowered border, shadows are on top and highlights128* are underneath.)129*130* @param type an integer specifying either131* <code>BevelBorder.LOWERED</code> or132* <code>BevelBorder.RAISED</code>133* @return the <code>Border</code> object134*/135public static Border createBevelBorder(int type) {136return createSharedBevel(type);137}138139/**140* Creates a beveled border of the specified type, using141* the specified highlighting and shadowing. The outer142* edge of the highlighted area uses a brighter shade of143* the highlight color. The inner edge of the shadow area144* uses a brighter shade of the shadow color.145*146* @param type an integer specifying either147* <code>BevelBorder.LOWERED</code> or148* <code>BevelBorder.RAISED</code>149* @param highlight a <code>Color</code> object for highlights150* @param shadow a <code>Color</code> object for shadows151* @return the <code>Border</code> object152*/153public static Border createBevelBorder(int type, Color highlight, Color shadow) {154return new BevelBorder(type, highlight, shadow);155}156157/**158* Creates a beveled border of the specified type, using159* the specified colors for the inner and outer highlight160* and shadow areas.161*162* @param type an integer specifying either163* <code>BevelBorder.LOWERED</code> or164* <code>BevelBorder.RAISED</code>165* @param highlightOuter a <code>Color</code> object for the166* outer edge of the highlight area167* @param highlightInner a <code>Color</code> object for the168* inner edge of the highlight area169* @param shadowOuter a <code>Color</code> object for the170* outer edge of the shadow area171* @param shadowInner a <code>Color</code> object for the172* inner edge of the shadow area173* @return the <code>Border</code> object174*/175public static Border createBevelBorder(int type,176Color highlightOuter, Color highlightInner,177Color shadowOuter, Color shadowInner) {178return new BevelBorder(type, highlightOuter, highlightInner,179shadowOuter, shadowInner);180}181182static Border createSharedBevel(int type) {183if(type == BevelBorder.RAISED) {184return sharedRaisedBevel;185} else if(type == BevelBorder.LOWERED) {186return sharedLoweredBevel;187}188return null;189}190191//// SoftBevelBorder ///////////////////////////////////////////////////////////192////////////////////////////////////////////////////////////////////////////////193194private static Border sharedSoftRaisedBevel;195private static Border sharedSoftLoweredBevel;196197/**198* Creates a beveled border with a raised edge and softened corners,199* using brighter shades of the component's current background color200* for highlighting, and darker shading for shadows.201* In a raised border, highlights are on top and shadows are underneath.202*203* @return the {@code Border} object204*205* @since 1.7206*/207public static Border createRaisedSoftBevelBorder() {208if (sharedSoftRaisedBevel == null) {209sharedSoftRaisedBevel = new SoftBevelBorder(BevelBorder.RAISED);210}211return sharedSoftRaisedBevel;212}213214/**215* Creates a beveled border with a lowered edge and softened corners,216* using brighter shades of the component's current background color217* for highlighting, and darker shading for shadows.218* In a lowered border, shadows are on top and highlights are underneath.219*220* @return the {@code Border} object221*222* @since 1.7223*/224public static Border createLoweredSoftBevelBorder() {225if (sharedSoftLoweredBevel == null) {226sharedSoftLoweredBevel = new SoftBevelBorder(BevelBorder.LOWERED);227}228return sharedSoftLoweredBevel;229}230231/**232* Creates a beveled border of the specified type with softened corners,233* using brighter shades of the component's current background color234* for highlighting, and darker shading for shadows.235* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.236*237* @param type a type of a bevel238* @return the {@code Border} object or {@code null}239* if the specified type is not valid240*241* @see BevelBorder#BevelBorder(int)242* @since 1.7243*/244public static Border createSoftBevelBorder(int type) {245if (type == BevelBorder.RAISED) {246return createRaisedSoftBevelBorder();247}248if (type == BevelBorder.LOWERED) {249return createLoweredSoftBevelBorder();250}251return null;252}253254/**255* Creates a beveled border of the specified type with softened corners,256* using the specified highlighting and shadowing.257* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.258* The outer edge of the highlight area uses259* a brighter shade of the {@code highlight} color.260* The inner edge of the shadow area uses261* a brighter shade of the {@code shadow} color.262*263* @param type a type of a bevel264* @param highlight a basic color of the highlight area265* @param shadow a basic color of the shadow area266* @return the {@code Border} object267*268* @see BevelBorder#BevelBorder(int, Color, Color)269* @since 1.7270*/271public static Border createSoftBevelBorder(int type, Color highlight, Color shadow) {272return new SoftBevelBorder(type, highlight, shadow);273}274275/**276* Creates a beveled border of the specified type with softened corners,277* using the specified colors for the inner and outer edges278* of the highlight and the shadow areas.279* The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}.280* Note: The shadow inner and outer colors are switched281* for a lowered bevel border.282*283* @param type a type of a bevel284* @param highlightOuter a color of the outer edge of the highlight area285* @param highlightInner a color of the inner edge of the highlight area286* @param shadowOuter a color of the outer edge of the shadow area287* @param shadowInner a color of the inner edge of the shadow area288* @return the {@code Border} object289*290* @see BevelBorder#BevelBorder(int, Color, Color, Color, Color)291* @since 1.7292*/293public static Border createSoftBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner) {294return new SoftBevelBorder(type, highlightOuter, highlightInner, shadowOuter, shadowInner);295}296297//// EtchedBorder ///////////////////////////////////////////////////////////298299static final Border sharedEtchedBorder = new EtchedBorder();300private static Border sharedRaisedEtchedBorder;301302/**303* Creates a border with an "etched" look using304* the component's current background color for305* highlighting and shading.306*307* @return the <code>Border</code> object308*/309public static Border createEtchedBorder() {310return sharedEtchedBorder;311}312313/**314* Creates a border with an "etched" look using315* the specified highlighting and shading colors.316*317* @param highlight a <code>Color</code> object for the border highlights318* @param shadow a <code>Color</code> object for the border shadows319* @return the <code>Border</code> object320*/321public static Border createEtchedBorder(Color highlight, Color shadow) {322return new EtchedBorder(highlight, shadow);323}324325/**326* Creates a border with an "etched" look using327* the component's current background color for328* highlighting and shading.329*330* @param type one of <code>EtchedBorder.RAISED</code>, or331* <code>EtchedBorder.LOWERED</code>332* @return the <code>Border</code> object333* @exception IllegalArgumentException if type is not either334* <code>EtchedBorder.RAISED</code> or335* <code>EtchedBorder.LOWERED</code>336* @since 1.3337*/338public static Border createEtchedBorder(int type) {339switch (type) {340case EtchedBorder.RAISED:341if (sharedRaisedEtchedBorder == null) {342sharedRaisedEtchedBorder = new EtchedBorder343(EtchedBorder.RAISED);344}345return sharedRaisedEtchedBorder;346case EtchedBorder.LOWERED:347return sharedEtchedBorder;348default:349throw new IllegalArgumentException("type must be one of EtchedBorder.RAISED or EtchedBorder.LOWERED");350}351}352353/**354* Creates a border with an "etched" look using355* the specified highlighting and shading colors.356*357* @param type one of <code>EtchedBorder.RAISED</code>, or358* <code>EtchedBorder.LOWERED</code>359* @param highlight a <code>Color</code> object for the border highlights360* @param shadow a <code>Color</code> object for the border shadows361* @return the <code>Border</code> object362* @since 1.3363*/364public static Border createEtchedBorder(int type, Color highlight,365Color shadow) {366return new EtchedBorder(type, highlight, shadow);367}368369//// TitledBorder ////////////////////////////////////////////////////////////370/**371* Creates a new titled border with the specified title,372* the default border type (determined by the current look and feel),373* the default text position (determined by the current look and feel),374* the default justification (leading), and the default375* font and text color (determined by the current look and feel).376*377* @param title a <code>String</code> containing the text of the title378* @return the <code>TitledBorder</code> object379*/380public static TitledBorder createTitledBorder(String title) {381return new TitledBorder(title);382}383384/**385* Creates a new titled border with an empty title,386* the specified border object,387* the default text position (determined by the current look and feel),388* the default justification (leading), and the default389* font and text color (determined by the current look and feel).390*391* @param border the <code>Border</code> object to add the title to; if392* <code>null</code> the <code>Border</code> is determined393* by the current look and feel.394* @return the <code>TitledBorder</code> object395*/396public static TitledBorder createTitledBorder(Border border) {397return new TitledBorder(border);398}399400/**401* Adds a title to an existing border,402* with default positioning (determined by the current look and feel),403* default justification (leading) and the default404* font and text color (determined by the current look and feel).405*406* @param border the <code>Border</code> object to add the title to407* @param title a <code>String</code> containing the text of the title408* @return the <code>TitledBorder</code> object409*/410public static TitledBorder createTitledBorder(Border border,411String title) {412return new TitledBorder(border, title);413}414415/**416* Adds a title to an existing border, with the specified417* positioning and using the default418* font and text color (determined by the current look and feel).419*420* @param border the <code>Border</code> object to add the title to421* @param title a <code>String</code> containing the text of the title422* @param titleJustification an integer specifying the justification423* of the title -- one of the following:424*<ul>425*<li><code>TitledBorder.LEFT</code>426*<li><code>TitledBorder.CENTER</code>427*<li><code>TitledBorder.RIGHT</code>428*<li><code>TitledBorder.LEADING</code>429*<li><code>TitledBorder.TRAILING</code>430*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading)431*</ul>432* @param titlePosition an integer specifying the vertical position of433* the text in relation to the border -- one of the following:434*<ul>435*<li><code> TitledBorder.ABOVE_TOP</code>436*<li><code>TitledBorder.TOP</code> (sitting on the top line)437*<li><code>TitledBorder.BELOW_TOP</code>438*<li><code>TitledBorder.ABOVE_BOTTOM</code>439*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)440*<li><code>TitledBorder.BELOW_BOTTOM</code>441*<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position442* is determined by the current look and feel)443*</ul>444* @return the <code>TitledBorder</code> object445*/446public static TitledBorder createTitledBorder(Border border,447String title,448int titleJustification,449int titlePosition) {450return new TitledBorder(border, title, titleJustification,451titlePosition);452}453454/**455* Adds a title to an existing border, with the specified456* positioning and font, and using the default text color457* (determined by the current look and feel).458*459* @param border the <code>Border</code> object to add the title to460* @param title a <code>String</code> containing the text of the title461* @param titleJustification an integer specifying the justification462* of the title -- one of the following:463*<ul>464*<li><code>TitledBorder.LEFT</code>465*<li><code>TitledBorder.CENTER</code>466*<li><code>TitledBorder.RIGHT</code>467*<li><code>TitledBorder.LEADING</code>468*<li><code>TitledBorder.TRAILING</code>469*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading)470*</ul>471* @param titlePosition an integer specifying the vertical position of472* the text in relation to the border -- one of the following:473*<ul>474*<li><code> TitledBorder.ABOVE_TOP</code>475*<li><code>TitledBorder.TOP</code> (sitting on the top line)476*<li><code>TitledBorder.BELOW_TOP</code>477*<li><code>TitledBorder.ABOVE_BOTTOM</code>478*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)479*<li><code>TitledBorder.BELOW_BOTTOM</code>480*<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position481* is determined by the current look and feel)482*</ul>483* @param titleFont a Font object specifying the title font484* @return the TitledBorder object485*/486public static TitledBorder createTitledBorder(Border border,487String title,488int titleJustification,489int titlePosition,490Font titleFont) {491return new TitledBorder(border, title, titleJustification,492titlePosition, titleFont);493}494495/**496* Adds a title to an existing border, with the specified497* positioning, font and color.498*499* @param border the <code>Border</code> object to add the title to500* @param title a <code>String</code> containing the text of the title501* @param titleJustification an integer specifying the justification502* of the title -- one of the following:503*<ul>504*<li><code>TitledBorder.LEFT</code>505*<li><code>TitledBorder.CENTER</code>506*<li><code>TitledBorder.RIGHT</code>507*<li><code>TitledBorder.LEADING</code>508*<li><code>TitledBorder.TRAILING</code>509*<li><code>TitledBorder.DEFAULT_JUSTIFICATION</code> (leading)510*</ul>511* @param titlePosition an integer specifying the vertical position of512* the text in relation to the border -- one of the following:513*<ul>514*<li><code> TitledBorder.ABOVE_TOP</code>515*<li><code>TitledBorder.TOP</code> (sitting on the top line)516*<li><code>TitledBorder.BELOW_TOP</code>517*<li><code>TitledBorder.ABOVE_BOTTOM</code>518*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)519*<li><code>TitledBorder.BELOW_BOTTOM</code>520*<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position521* is determined by the current look and feel)522*</ul>523* @param titleFont a <code>Font</code> object specifying the title font524* @param titleColor a <code>Color</code> object specifying the title color525* @return the <code>TitledBorder</code> object526*/527public static TitledBorder createTitledBorder(Border border,528String title,529int titleJustification,530int titlePosition,531Font titleFont,532Color titleColor) {533return new TitledBorder(border, title, titleJustification,534titlePosition, titleFont, titleColor);535}536//// EmptyBorder ///////////////////////////////////////////////////////////537final static Border emptyBorder = new EmptyBorder(0, 0, 0, 0);538539/**540* Creates an empty border that takes up no space. (The width541* of the top, bottom, left, and right sides are all zero.)542*543* @return the <code>Border</code> object544*/545public static Border createEmptyBorder() {546return emptyBorder;547}548549/**550* Creates an empty border that takes up space but which does551* no drawing, specifying the width of the top, left, bottom, and552* right sides.553*554* @param top an integer specifying the width of the top,555* in pixels556* @param left an integer specifying the width of the left side,557* in pixels558* @param bottom an integer specifying the width of the bottom,559* in pixels560* @param right an integer specifying the width of the right side,561* in pixels562* @return the <code>Border</code> object563*/564public static Border createEmptyBorder(int top, int left,565int bottom, int right) {566return new EmptyBorder(top, left, bottom, right);567}568569//// CompoundBorder ////////////////////////////////////////////////////////570/**571* Creates a compound border with a <code>null</code> inside edge and a572* <code>null</code> outside edge.573*574* @return the <code>CompoundBorder</code> object575*/576public static CompoundBorder createCompoundBorder() {577return new CompoundBorder();578}579580/**581* Creates a compound border specifying the border objects to use582* for the outside and inside edges.583*584* @param outsideBorder a <code>Border</code> object for the outer585* edge of the compound border586* @param insideBorder a <code>Border</code> object for the inner587* edge of the compound border588* @return the <code>CompoundBorder</code> object589*/590public static CompoundBorder createCompoundBorder(Border outsideBorder,591Border insideBorder) {592return new CompoundBorder(outsideBorder, insideBorder);593}594595//// MatteBorder ////////////////////////////////////////////////////////596/**597* Creates a matte-look border using a solid color. (The difference between598* this border and a line border is that you can specify the individual599* border dimensions.)600*601* @param top an integer specifying the width of the top,602* in pixels603* @param left an integer specifying the width of the left side,604* in pixels605* @param bottom an integer specifying the width of the right side,606* in pixels607* @param right an integer specifying the width of the bottom,608* in pixels609* @param color a <code>Color</code> to use for the border610* @return the <code>MatteBorder</code> object611*/612public static MatteBorder createMatteBorder(int top, int left, int bottom, int right,613Color color) {614return new MatteBorder(top, left, bottom, right, color);615}616617/**618* Creates a matte-look border that consists of multiple tiles of a619* specified icon. Multiple copies of the icon are placed side-by-side620* to fill up the border area.621* <p>622* Note:<br>623* If the icon doesn't load, the border area is painted gray.624*625* @param top an integer specifying the width of the top,626* in pixels627* @param left an integer specifying the width of the left side,628* in pixels629* @param bottom an integer specifying the width of the right side,630* in pixels631* @param right an integer specifying the width of the bottom,632* in pixels633* @param tileIcon the <code>Icon</code> object used for the border tiles634* @return the <code>MatteBorder</code> object635*/636public static MatteBorder createMatteBorder(int top, int left, int bottom, int right,637Icon tileIcon) {638return new MatteBorder(top, left, bottom, right, tileIcon);639}640641//// StrokeBorder //////////////////////////////////////////////////////////////642////////////////////////////////////////////////////////////////////////////////643644/**645* Creates a border of the specified {@code stroke}.646* The component's foreground color will be used to render the border.647*648* @param stroke the {@link BasicStroke} object used to stroke a shape649* @return the {@code Border} object650*651* @throws NullPointerException if the specified {@code stroke} is {@code null}652*653* @since 1.7654*/655public static Border createStrokeBorder(BasicStroke stroke) {656return new StrokeBorder(stroke);657}658659/**660* Creates a border of the specified {@code stroke} and {@code paint}.661* If the specified {@code paint} is {@code null},662* the component's foreground color will be used to render the border.663*664* @param stroke the {@link BasicStroke} object used to stroke a shape665* @param paint the {@link Paint} object used to generate a color666* @return the {@code Border} object667*668* @throws NullPointerException if the specified {@code stroke} is {@code null}669*670* @since 1.7671*/672public static Border createStrokeBorder(BasicStroke stroke, Paint paint) {673return new StrokeBorder(stroke, paint);674}675676//// DashedBorder //////////////////////////////////////////////////////////////677////////////////////////////////////////////////////////////////////////////////678679private static Border sharedDashedBorder;680681/**682* Creates a dashed border of the specified {@code paint}.683* If the specified {@code paint} is {@code null},684* the component's foreground color will be used to render the border.685* The width of a dash line is equal to {@code 1}.686* The relative length of a dash line and687* the relative spacing between dash lines are equal to {@code 1}.688* A dash line is not rounded.689*690* @param paint the {@link Paint} object used to generate a color691* @return the {@code Border} object692*693* @since 1.7694*/695public static Border createDashedBorder(Paint paint) {696return createDashedBorder(paint, 1.0f, 1.0f, 1.0f, false);697}698699/**700* Creates a dashed border of the specified {@code paint},701* relative {@code length}, and relative {@code spacing}.702* If the specified {@code paint} is {@code null},703* the component's foreground color will be used to render the border.704* The width of a dash line is equal to {@code 1}.705* A dash line is not rounded.706*707* @param paint the {@link Paint} object used to generate a color708* @param length the relative length of a dash line709* @param spacing the relative spacing between dash lines710* @return the {@code Border} object711*712* @throws IllegalArgumentException if the specified {@code length} is less than {@code 1}, or713* if the specified {@code spacing} is less than {@code 0}714* @since 1.7715*/716public static Border createDashedBorder(Paint paint, float length, float spacing) {717return createDashedBorder(paint, 1.0f, length, spacing, false);718}719720/**721* Creates a dashed border of the specified {@code paint}, {@code thickness},722* line shape, relative {@code length}, and relative {@code spacing}.723* If the specified {@code paint} is {@code null},724* the component's foreground color will be used to render the border.725*726* @param paint the {@link Paint} object used to generate a color727* @param thickness the width of a dash line728* @param length the relative length of a dash line729* @param spacing the relative spacing between dash lines730* @param rounded whether or not line ends should be round731* @return the {@code Border} object732*733* @throws IllegalArgumentException if the specified {@code thickness} is less than {@code 1}, or734* if the specified {@code length} is less than {@code 1}, or735* if the specified {@code spacing} is less than {@code 0}736* @since 1.7737*/738public static Border createDashedBorder(Paint paint, float thickness, float length, float spacing, boolean rounded) {739boolean shared = !rounded && (paint == null) && (thickness == 1.0f) && (length == 1.0f) && (spacing == 1.0f);740if (shared && (sharedDashedBorder != null)) {741return sharedDashedBorder;742}743if (thickness < 1.0f) {744throw new IllegalArgumentException("thickness is less than 1");745}746if (length < 1.0f) {747throw new IllegalArgumentException("length is less than 1");748}749if (spacing < 0.0f) {750throw new IllegalArgumentException("spacing is less than 0");751}752int cap = rounded ? BasicStroke.CAP_ROUND : BasicStroke.CAP_SQUARE;753int join = rounded ? BasicStroke.JOIN_ROUND : BasicStroke.JOIN_MITER;754float[] array = { thickness * (length - 1.0f), thickness * (spacing + 1.0f) };755Border border = createStrokeBorder(new BasicStroke(thickness, cap, join, thickness * 2.0f, array, 0.0f), paint);756if (shared) {757sharedDashedBorder = border;758}759return border;760}761}762763764