package javafx_uitabpane;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_uiTabPane extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("http://java-buddy.blogspot.com/");
Group root = new Group();
Scene scene = new Scene(root, 400, 300, Color.WHITE);
TabPane tabPane = new TabPane();
BorderPane mainPane = new BorderPane();
//Create Tabs
Tab tabA = new Tab();
tabA.setText("Tab A");
tabPane.getTabs().add(tabA);
Tab tabB = new Tab();
tabB.setText("Tab B");
tabPane.getTabs().add(tabB);
Tab tabC = new Tab();
tabC.setText("Tab C");
tabPane.getTabs().add(tabC);
mainPane.setCenter(tabPane);
mainPane.prefHeightProperty().bind(scene.heightProperty());
mainPane.prefWidthProperty().bind(scene.widthProperty());
root.getChildren().add(mainPane);
primaryStage.setScene(scene);
primaryStage.show();
}
}
next:
- Add content to Tabs
Hey,
ReplyDeleteHow do you change 'selected tab' through the code? Lets say i want TabB to be the 'selected' one when the application launches instead of the default tabA being the 'selected' one!
Thanks
Look here
Deletehttp://stackoverflow.com/questions/6902377/javafx-tabpane-how-to-set-the-selected-tab
hey can you please answer this
ReplyDeletehttp://stackoverflow.com/questions/26093045/add-tabs-to-next-line-in-javafx