The BorderFactory class, which is in the javax.swing package, returns objects that implement the 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, 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. 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))
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |