19.09.2015 Views

Prentice.Hall.Introduction.to.Java.Programming,.Brief.Version.9th.(2014).[sharethefiles.com]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

11 public DisplayFigure() {<br />

12 squarePanel.setType(FigurePanel.LINE);<br />

13 rectanglePanel.setType(FigurePanel.RECTANGLE);<br />

14 circlePanel.setType(FigurePanel.ROUND_RECTANGLE);<br />

15 ovalPanel.setType(FigurePanel.OVAL);<br />

16<br />

17 add(jtpFigures, BorderLayout.CENTER);<br />

18 jtpFigures.add(squarePanel, "Line");<br />

19 jtpFigures.add(rectanglePanel, "Rectangle");<br />

20 jtpFigures.add(circlePanel, "Round Rectangle");<br />

21 jtpFigures.add(ovalPanel, "Oval");<br />

22<br />

23 jtpFigures.setToolTipTextAt(0, "Square");<br />

24 jtpFigures.setToolTipTextAt(1, "Rectangle");<br />

25 jtpFigures.setToolTipTextAt(2, "Circle");<br />

26 jtpFigures.setToolTipTextAt(3, "Oval");<br />

27 }<br />

28 }<br />

The program creates a tabbed pane <strong>to</strong> hold four panels, each of which<br />

displays a figure. A panel is associated with a tab. The tabs are<br />

titled Line, Rectangle, Rounded Rectangle, and Oval.<br />

By default, the tabs are placed at the <strong>to</strong>p of the tabbed pane. You can<br />

select a different placement using the tabPlacement property.<br />

37.7 JSplitPane<br />

JSplitPane is a convenient Swing container that contains two<br />

<strong>com</strong>ponents with a separate bar known as a divider, as shown in Figure<br />

37.15.<br />

(a) Vertical divider<br />

(b) Horizontal divider<br />

Figure 37.15<br />

JSplitPane divides a container in<strong>to</strong> two parts.<br />

The bar can divide the container horizontally or vertically and can be<br />

dragged <strong>to</strong> change the amount of space occupied by each <strong>com</strong>ponent.<br />

Figure 37.16 shows the frequently used properties, construc<strong>to</strong>rs, and<br />

methods in JSplitPane<br />

.<br />

27

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!