- ADD BORDER TO TEXT BOX IN JAVA HOW TO
- ADD BORDER TO TEXT BOX IN JAVA CODE
- ADD BORDER TO TEXT BOX IN JAVA DOWNLOAD
- ADD BORDER TO TEXT BOX IN JAVA WINDOWS
The API for using borders falls into two categories:
The following tables list the commonly used border methods.
ADD BORDER TO TEXT BOX IN JAVA CODE
If a custom border has insets (and they typically have insets) you need to override bothĪbstractBorder.getBorderInsets(Component c) andĪbstractBorder.getBorderInsets(Component c, Insets insets) to provide the correct insets.įor examples of implementing borders, see the source code for the classes in the package.
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,
ADD BORDER TO TEXT BOX IN JAVA 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.
ADD BORDER TO TEXT BOX IN JAVA WINDOWS
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.
ADD BORDER TO TEXT BOX IN JAVA 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))