2017-03-20 1 views
0

BorderPane 오른쪽의 VBox을 사용하여 접을 수있는 사이드 바를 만들었습니다. 이 사이드 바에서는 선택한 클래스의 소스 코드 (거품이라고도 함)를 목록 아래에 하나씩 표시합니다. 각 거품의 폭은 300px, 높이는 700px입니다. 그러나 사이드 바에 새로운 버블을 추가하면 목록의 다른 버블이 줄어들 기 시작했습니다. 대신이 스크롤 바를 가지고 싶습니다. 사이드 바 VBox. 내가 어떻게 이걸 이룰 수 있니? 여기 JavaFx에서 스크롤 가능한 VBox 만들기

void initSideBarActions() { 
    sideBar = new SideBarView(borderPane); 
    borderPane.setRight(sideBar); 

    String sourceCode = "public class FXMLDocumentController implements Initializable {\n" + 
      " @FXML\n" + 
      " AnchorPane apMain;\n" + 
      "\n" + 
      " @Override\n" + 
      " public void initialize(URL url, ResourceBundle rb)\n" + 
      " {\n" + 
      "   BubbleShape bs = new BubbleShape(\"Hello world!\");\n" + 
      "   bs.setLayoutX(50.0);\n" + 
      "   bs.setLayoutY(50.0);\n" + 
      "\n" + 
      "   BubbleShape bs2 = new BubbleShape(\"Bye world!\");\n" + 
      "   bs2.setLayoutX(400);\n" + 
      "   bs2.setLayoutY(400);\n" + 
      "   apMain.getChildren().addAll(bs, bs2);\n" + 
      " }\n" + 
      "}"; 

    BubbleView bubble1 = new BubbleView(sourceCode, "SampleClassOne"); 
    BubbleView bubble2 = new BubbleView(sourceCode, "SampleClassTwo"); 
    BubbleView bubble3 = new BubbleView(sourceCode, "SampleClassThree"); 

    sideBar.addNewBubble(bubble1); 
    sideBar.addNewBubble(bubble2); 
    sideBar.addNewBubble(bubble3); 
} 

는 스크린 샷입니다 :

Screenshot of the current version

여기에 .fxml 파일 : 나는이 질문 (How to create a scrollable panel of components in JavaFX?)를 읽을하더라도

<?xml version="1.0" encoding="UTF-8"?> 

<?import javafx.scene.layout.BorderPane?> 
<?import javafx.scene.layout.Pane?> 
<?import javafx.scene.control.ToolBar?> 
<?import javafx.scene.control.Button?> 
<?import javafx.scene.layout.VBox?> 
<?import javafx.scene.control.Slider?> 
<?import javafx.scene.control.Label?> 
<?import javafx.scene.layout.HBox?> 
<?import javafx.scene.control.ScrollPane?> 
<?import javafx.scene.control.ScrollPane?> 
<?import javafx.scene.control.ColorPicker?> 
<?import javafx.scene.layout.StackPane?> 

<BorderPane fx:id="borderPane" fx:controller="com.kaanburaksener.octoUML.src.controller.ClassDiagramController" xmlns:fx="http://javafx.com/fxml"> 
    <top> 
     <VBox> 
      <ToolBar fx:id="aToolBar" orientation="HORIZONTAL"> 
       <HBox fx:id="umlBox"> 
        <Button text="Create" fx:id="createBtn"/> 
        <Button text="Enumeration" fx:id="enumBtn"/> 
        <Button text="Package" fx:id="packageBtn"/> 
        <Button text="Edge" fx:id="edgeBtn"/> 
        <Button text="Draw" fx:id="drawBtn"/> 
       </HBox> 
       <HBox fx:id="utilBox"> 
        <Button text="Select" fx:id="selectBtn"/> 
        <Button text="Move" fx:id="moveBtn"/> 
       </HBox> 
       <HBox fx:id="undoBox"> 
        <Button text="Delete" fx:id="deleteBtn"/> 
        <Button text="Undo" fx:id="undoBtn"/> 
        <Button text="Redo" fx:id="redoBtn"/> 
       </HBox> 
       <HBox fx:id="recognizeBox"> 
        <Button text="Source Code" fx:id="sourceCodeBtn"/> 
        <Button text="Recognize" fx:id="recognizeBtn"/> 
        <Button text="Voice" fx:id="voiceBtn"/> 
       </HBox> 
      </ToolBar> 
     </VBox> 
    </top> 
    <bottom> 
     <StackPane fx:id="infoPane"> 
      <ToolBar fx:id="zoomPane"> 
       <Pane HBox.hgrow="ALWAYS" /> 
       <VBox alignment="CENTER"> 
        <Slider fx:id="zoomSlider" min="10" max="200" value="100"/> 
        <Label fx:id="zoomLabel" text="Zoom" /> 
       </VBox> 
       <Pane HBox.hgrow="ALWAYS" /> 
      </ToolBar> 
      <ColorPicker fx:id="colorPicker" StackPane.alignment="CENTER_LEFT"/> 
      <Label fx:id="serverLabel" StackPane.alignment="CENTER_RIGHT"/> 
     </StackPane> 
    </bottom> 
    <center> 
     <ScrollPane fx:id="scrollPane" pannable="true" BorderPane.alignment="CENTER"> 
      <content> 
       <Pane fx:id="drawPane" prefHeight="8000.0" prefWidth="8000.0"> 
       </Pane> 
      </content> 
     </ScrollPane> 
    </center> 
</BorderPane> 

, I 내 프로젝트에 솔루션을 적용 할 수 없었습니다.

답변

4

스크롤 창에 사이드 바를 감싸기 만하면됩니다. 세로로만 스크롤 할 수있게하려면 setFitToWidth(true)으로 전화하십시오.

sideBar = new SideBarView(borderPane); 

ScrollPane sideBarScroller = new ScrollPane(sideBar); 
sideBarScroller.setFitToWidth(true); 

borderPane.setRight(sideBarScroller); 
관련 문제