執行結果:

分頁  


import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class NewClass extends Application {

    @Override
    public void start(Stage s) {
        s.setTitle("分頁");
        Group root = new Group();
        Scene scene = new Scene(root, 400, 250, Color.WHITE);

        TabPane tp = new TabPane();

        BorderPane bp = new BorderPane();
        for (int i = 0; i < 10; i++) {
            Tab tab = new Tab();
            tab.setText("分頁 " + i);
            HBox hbox = new HBox();
            hbox.getChildren().add(new Label("分頁 " + i));
            hbox.setAlignment(Pos.CENTER);
            tab.setContent(hbox);
            tp.getTabs().add(tab);
        }

        bp.prefHeightProperty().bind(scene.heightProperty());
        bp.prefWidthProperty().bind(scene.widthProperty());

        bp.setCenter(tp);
        root.getChildren().add(bp);
        s.setScene(scene);
        s.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}





arrow
arrow
    全站熱搜

    黃彥霖 發表在 痞客邦 留言(0) 人氣()