2016-08-30 12 views
0
package com.ge.health.signaturegenerator; 

import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 

import javafx.application.Application; 
import javafx.geometry.Insets; 
import javafx.geometry.Side; 
import javafx.scene.Scene; 
import javafx.scene.control.Button; 
import javafx.scene.control.Label; 
import javafx.scene.control.Menu; 
import javafx.scene.control.MenuBar; 
import javafx.scene.control.MenuItem; 
import javafx.scene.control.Tab; 
import javafx.scene.control.TabPane; 
import javafx.scene.control.TabPane.TabClosingPolicy; 
import javafx.scene.control.TitledPane; 
import javafx.scene.image.Image; 
import javafx.scene.image.ImageView; 
import javafx.scene.layout.BorderPane; 
import javafx.scene.layout.ColumnConstraints; 
import javafx.scene.layout.GridPane; 
import javafx.scene.layout.HBox; 
import javafx.scene.layout.VBox; 
import javafx.scene.paint.Color; 
import javafx.stage.Stage; 

public class Main2 extends Application { 

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

    @Override 
    public void start(Stage primaryStage) throws FileNotFoundException { 
     primaryStage.setTitle("Signature Generator"); 
     VBox rootBox = new VBox(); 
     Scene scene = new Scene(rootBox, 1600, 950, Color.TRANSPARENT); 
     scene.getStylesheets().add("NewFile.css"); 
     rootBox.setStyle("-fx-background-color: #A9A9A9;"); 

     MenuBar bar = new MenuBar(); 
     bar.setStyle("-fx-background-color: #A9A9A9; -fx-border-color: black; -fx-border-width: 0.5;"); 

     Menu fileMenu = new Menu("File"); 
     fileMenu.getItems().add(new MenuItem("Load")); 

     bar.getMenus().add(fileMenu); 
     bar.getMenus().add(new Menu("Help")); 

     rootBox.getChildren().add(bar); 

     GridPane headerPane = new GridPane(); 
     headerPane.setPadding(new Insets(5)); 
     headerPane.setHgap(5); 
     headerPane.setVgap(5); 
     ColumnConstraints column1 = new ColumnConstraints(200); 
     ColumnConstraints column2 = new ColumnConstraints(200); 
     ColumnConstraints column3 = new ColumnConstraints(200); 
     ColumnConstraints column4 = new ColumnConstraints(200); 
     headerPane.getColumnConstraints().addAll(column1, column2, column3, column4); 

     Label ageLabel = new Label("Age : 68"); 
     Label heightLabel = new Label("Height : 180 cm"); 
     Label widthLabel = new Label("width : 75 cm"); 
     Button button1 = new Button("Generate Atlas"); 
     headerPane.add(ageLabel, 0, 0); 
     headerPane.add(heightLabel, 1, 0); 
     headerPane.add(widthLabel, 2, 0); 
     headerPane.add(button1, 3, 0); 
     headerPane.setStyle("-fx-background-color: #A9A9A9;"); 
     rootBox.getChildren().add(headerPane); 

     TabPane tabPane = new TabPane(); 
     tabPane.setSide(Side.LEFT); 
     tabPane.setTabMinHeight(300); 
     tabPane.setTabMaxWidth(15); 
     tabPane.setStyle("-fx-border-color: black; -fx-border-width: 1; -fx-open-tab-animation: grow;"); 
     tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); 

     for (int i = 0; i < 15; i++) { 
      Tab tab = new Tab(); 
      Label l = new Label("Tab " + i + "Tab " + i + "Tab " + i + "Tab " + i); 
      l.setStyle("-fx-rotate: 90;"); 
      l.setMinSize(200, 40); 
      tab.setGraphic(l); 
      tab.getGraphic().autosize(); 
      tab.setStyle("-fx-background-color: #A9A9A9;"); 
      tab.setClosable(false); 

      ImageView imView = null; 
      int j = i % 2; 
      if (j == 0) { 
       imView = new ImageView(new Image(
         new FileInputStream(new File("C:/Users/502655636/Pictures/2016-08-19_17h23_08.png")))); 
      } else { 
       imView = new ImageView(new Image(
         new FileInputStream(new File("C:/Users/502655636/Pictures/2016-08-19_17h07_40.png")))); 
      } 

      GridPane grid = new GridPane(); 
      VBox vbox = new VBox(imView); 
      grid.add(vbox, 0, 0, 1, 6); 
      grid.setStyle("-fx-background-color: #FFFFFF;"); 

      TitledPane[] titledPaneTab = new TitledPane[6]; 
      for (int k = 0; k < 6; k++) { 
       GridPane buttonsGrid = new GridPane(); 
       buttonsGrid.setPadding(new Insets(5)); 
       buttonsGrid.setHgap(5); 
       buttonsGrid.setVgap(5); 
       ColumnConstraints buttonColumn1 = new ColumnConstraints(100); 
       buttonsGrid.getColumnConstraints().addAll(buttonColumn1); 

       buttonsGrid.add(new HBox(), 0, 0); 
       Label read = new Label("Read pos. : "); 
       read.setMinWidth(100); 
       Label selected = new Label("Selected pos. : "); 
       selected.setMinWidth(100); 
       HBox box1 = new HBox(100, read, selected); 
       buttonsGrid.add(box1, 0, 1); 

       Button mark = new Button("Mark"); 
       mark.setMinWidth(100); 
       Button delete = new Button("Delete"); 
       delete.setMinWidth(100); 
       Button reset = new Button("Reset"); 
       reset.setMinWidth(100); 
       HBox box2 = new HBox(10, mark, delete, reset); 
       buttonsGrid.add(box2, 0, 2); 
       buttonsGrid.setStyle("-fx-background-color: #A9A9A9;"); 

       TitledPane ggg = new TitledPane("Parts " + i, buttonsGrid); 

       ggg.setCollapsible(false); 

       ggg.setMinWidth(400); 
       ggg.setStyle("-fx-content-display: top; -fx-border-insets: 20 15 15 15; -fx-background-color: #FFFFFF; -fx-border-color: black; -fx-border-width: 1;");    

       titledPaneTab[k] = ggg; 
      } 
      VBox box2 = new VBox(titledPaneTab); 
      grid.addColumn(1, box2); 
      tab.setContent(grid); 
      tabPane.getTabs().add(tab); 
     } 

     // bind to take available space 
     BorderPane borderPane = new BorderPane(); 
     borderPane.prefHeightProperty().bind(scene.heightProperty()); 
     borderPane.prefWidthProperty().bind(scene.widthProperty()); 

     borderPane.setCenter(tabPane); 
     rootBox.getChildren().add(borderPane); 
     primaryStage.setScene(scene); 
     primaryStage.show(); 
    } 
} 

こんにちは。Javafx TabPaneが最後までスクロールできないTab

私はjavafxの小さなアプリケーションを開発しようとしています。

javafx TabPaneに問題が発生しました。ステージよりも多くのタブが表示できる場合は、ページの一番下にスクロールできません。

アイデアは誰でも。

私は

.tab-pane *.tab-header-background { 
    -fx-background-color: #000000; 
} 

.tab-pane *.tab:selected { 
    -fx-color: #FFFFFF; 
} 

も、このCSSを使用した結果は、矢印が現れ

Tab Pane with scroll

を下回っています。

問題は、ヘッダに30個のタブがあり、最後のものまでスクロールできないことです。私は矢印を通してそれを選択した場合でも、それは

あなたはスクロールペインにtabpaneを置くことができ、あなたに

+0

もっと具体的になりますか?たとえば、通常はスクロールすることができ、矢印も表示されます(これはこの例でも同様です)。 – DVarga

+0

ありがとうございます。はい、矢印が表示されます。問題は、私が選択したときに、最後のタブとしましょう、タブのヘッダーが選択されたタブを表示するために下部に自動スクロールしないということです – evil0606

+0

誰かが助けてくれるのですか? – evil0606

答えて

0

ありがとうござい表示されない - GlacialMan 8月31日の23時03分

でGlacialMan

ありがとう
+0

これは質問に対する答えではありません。追加の説明を追加するには、元の投稿を編集してください。 –

+0

コンテンツ編集。ごめんなさい :) – evil0606

関連する問題