Modify Listing 31.12, TabPaneDemo.java, to add a pane of radio buttons for specifying the tab placement of

Question:

Modify Listing 31.12, TabPaneDemo.java, to add a pane of radio buttons for specifying the tab placement of the tab pane, as shown in Figure 31.57b and c.

Data from Listing 31.12,

Listing 31.12 TabPaneDemo.java
1 import javafx.application.Application;
2 import javafx.scene.Scene;
3 import javafx.scene.control.Tab;
4 import javafx.scene.control.TabPane;
5 import javafx.scene.layout.StackPane;
6 import javafx.scene.shape.Circle;
7 import javafx.scene.shape.Ellipse;
8 import javafx.scene.shape.Line;
9 import javafx.scene.shape.Rectangle;
10 import javafx.stage.Stage;
11
12 public class TabPaneDemo extends Application {
13 @Override // Override the start method in the Application class
14 public void start(Stage primaryStage) {
15 TabPane tabPane = new TabPane();
16 Tab tab1 = new Tab("Line");
17 StackPane pane1 = new StackPane();
18 pane1.getChildren().add(new Line(10, 10, 80, 80));
19 tab1.setContent(pane1);
20 Tab tab2 = new Tab("Rectangle");
21 tab2.setContent(new Rectangle(10, 10, 200, 200));
22 Tab tab3 = new Tab("Circle");
23 tab3.setContent(new Circle(50, 50, 20));
24 Tab tab4 = new Tab("Ellipse");
25 tab4.setContent(new Ellipse(10, 10, 100, 80));
26 tabPane.getTabs().addAll(tab1, tab2, tab3, tab4);
27
28 Scene scene = new Scene(tabPane, 300, 250);
29 primaryStage.setTitle("DisplayFigure"); // Set the window title
30 primaryStage.setScene(scene); // Place the scene in the window
31 primaryStage.show(); // Display the window
32 }
33 }

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: