Every Show
Note: Our examples set borders on To put a border around a JPanel pane = new JPanel(); pane.setBorder(BorderFactory.createLineBorder(Color.black)); Here's a picture of the container, which contains a label component. The black line drawn by the border marks the edge of the container. The rest of this page discusses the following topics:
The BorderDemo ExampleThe following pictures show an application called Click the Launch button to run the BorderDemo example using Java™ Web Start (download JDK 7 or later). Alternatively, to compile and run the example yourself, consult the example index. The next picture shows some matte borders. When creating a matte border, you specify how many pixels it occupies at the top, left, bottom, and right of a component. You then specify either a color or an icon for the matte border to draw. 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. The next picture shows titled borders. Using a titled border, you can convert any border into one that displays a text description. If you don't specify a border, a look-and-feel-specific border is used. 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. By default, the title straddles the upper left of the border, as shown at the top of the following figure. The next picture shows compound borders. With compound borders, you can combine any two borders, which can themselves be compound borders. Using the Borders Provided by SwingThe code that follows shows how to create and set the borders you saw in the preceding figures. You can find the program's code in
//Keep references to the next few borders, //for use in titles and compound borders. Border blackline, raisedetched, loweredetched, raisedbevel, loweredbevel, empty; blackline = BorderFactory.createLineBorder(Color.black); raisedetched = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); raisedbevel = BorderFactory.createRaisedBevelBorder(); loweredbevel = BorderFactory.createLoweredBevelBorder(); empty = BorderFactory.createEmptyBorder(); //Simple borders jComp1.setBorder(blackline); jComp2.setBorder(raisedbevel); jComp3.setBorder(loweredbevel); jComp4.setBorder(empty); //Matte borders ImageIcon icon = createImageIcon("images/wavy.gif", "wavy-line border icon"); //20x22 jComp5.setBorder(BorderFactory.createMatteBorder( -1, -1, -1, -1, icon)); jComp6.setBorder(BorderFactory.createMatteBorder( 1, 5, 1, 1, Color.red)); jComp7.setBorder(BorderFactory.createMatteBorder( 0, 20, 0, 0, icon)); //Titled borders TitledBorder title; title = BorderFactory.createTitledBorder("title"); jComp8.setBorder(title); title = BorderFactory.createTitledBorder( blackline, "title"); title.setTitleJustification(TitledBorder.CENTER); jComp9.setBorder(title); title = BorderFactory.createTitledBorder( loweredetched, "title"); title.setTitleJustification(TitledBorder.RIGHT); jComp10.setBorder(title); title = BorderFactory.createTitledBorder( loweredbevel, "title"); title.setTitlePosition(TitledBorder.ABOVE_TOP); jComp11.setBorder(title); title = BorderFactory.createTitledBorder( empty, "title"); title.setTitlePosition(TitledBorder.BOTTOM); jComp12.setBorder(title); //Compound borders Border compound; Border redline = BorderFactory.createLineBorder(Color.red); //This creates a nice frame. compound = BorderFactory.createCompoundBorder( raisedbevel, loweredbevel); jComp13.setBorder(compound); //Add a red outline to the frame. compound = BorderFactory.createCompoundBorder( redline, compound); jComp14.setBorder(compound); //Add a title to the red-outlined frame. compound = BorderFactory.createTitledBorder( compound, "title", TitledBorder.CENTER, TitledBorder.BELOW_BOTTOM); jComp15.setBorder(compound); As you probably noticed, the code uses the The Creating Custom BordersIf If none of the Swing borders is suitable, you can implement your own border. Generally, you do this by creating a subclass of the
If a custom border has insets (and they typically have insets) you need to override both For examples of implementing borders, see the source code for the classes in the The Border APIThe following tables list the commonly used border methods. The API for using borders falls into two categories:
Examples that Use BordersMany examples in this lesson use borders. The following table lists a few interesting cases.
What are the small squares that appear in the corners and in the middle of the sides of a selected objects border called quizlet?a selected graphic appears surrounded by a SELECTION RECTANGLE, which has small squares and circles, called SIZING HANDLES, at each corner and middle location.
What is the placeholder that allows you to add a variety of objects called?Content placeholders are already formatted areas within in the slide layout where we can place different types of content such as, text, tables, charts, SmartArt, pictures, clipart or video. A Content placeholder is a placeholder you see on the typical Title and Content slide layout.
Which view do you choose if you want to see a thumbnail of each slide in a presentation arranged in a grid?Slide sorter view: In this view, you'll see a thumbnail version of each slide.
Which view do you choose if you want to see a thumbnail of each slide?Navigator view displays thumbnail images of each slide in the slide navigator on the left, and a full view of the selected content on the right. This is the default view for creating presentations. You can add, edit, rearrange, and delete slides in this view. in the toolbar, then choose Navigator.
|