- #HOW TO ADD BORDER TO TEXT IN PAINT HOW TO#
- #HOW TO ADD BORDER TO TEXT IN PAINT CODE#
- #HOW TO ADD BORDER TO TEXT IN PAINT DOWNLOAD#
In addition to containing the Border interface, the border package contains the classes that implement the borders you've already seen:ĬompoundBorder. If BorderFactory doesn't offer you enough control over a border's form, then you might need to directly use the API in the border package - or even define your own border. You often don't need to directly use anything in the border package, except when specifying constants that are specific to a particular border class or when referring to the Border type. The Border interface, as well as its Swing-provided implementations, is in the The BorderFactory class, which is in the javax.swing package, returns objects that implement the
#HOW TO ADD BORDER TO TEXT IN PAINT CODE#
tTitlePosition(TitledBorder.BOTTOM) īorder redline = BorderFactory.createLineBorder(Color.red) Ĭompound = BorderFactory.createCompoundBorder(Ĭompound = BorderFactory.createTitledBorder(Īs you probably noticed, the code uses the BorderFactory class to create each border. tTitleJustification(TitledBorder.CENTER) Title = BorderFactory.createTitledBorder( Title = BorderFactory.createTitledBorder("title") ImageIcon icon = createImageIcon("images/wavy.gif", Loweredbevel = BorderFactory.createLoweredBevelBorder() Įmpty = BorderFactory.createEmptyBorder() Raisedbevel = BorderFactory.createRaisedBevelBorder()
Loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED) Raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED) for use in titles and compound borders.īorder blackline, raisedetched, loweredetched,īlackline = BorderFactory.createLineBorder(Color.black) Keep references to the next few borders,
#HOW TO ADD BORDER TO TEXT IN PAINT HOW TO#
The code that follows shows how to create and set the borders you saw in the preceding figures.
With compound borders, you can combine any two borders, which can themselves be compound borders. By default, the title straddles the upper left of the border, as shown at the top of the following figure. For example, the default titled border in the Java look and feel uses a gray line, and the default titled border in the Windows look and feel uses an etched border. If you don't specify a border, a look-and-feel-specific border is used. Using a titled border, you can convert any border into one that displays a text description. You need to be careful when choosing the icon and determining your component's size otherwise, the icon might get chopped off or have mismatch at the component's corners. You then specify either a color or an icon for the matte border to draw. When creating a matte border, you specify how many pixels it occupies at the top, left, bottom, and right of a component.
The next picture shows some matte borders. Alternatively, to compile and run the example yourself, consult the example index.
#HOW TO ADD BORDER TO TEXT IN PAINT DOWNLOAD#
Java™ Web Start ( download JDK 7 or later). We show the code for creating these borders a little later, in Using the Borders Provided by Swing.Ĭlick the Launch button to run the BorderDemo example using The following pictures show an application called BorderDemo that displays the borders Swing provides. The rest of this page discusses the following topics: The black line drawn by the border marks the edge of the container. Here's a picture of the container, which contains a label component. tBorder(BorderFactory.createLineBorder(Color.black))