Results 1 to 2 of 2
  1. #1
    kalsan is offline Member
    Join Date
    Mar 2016
    Posts
    2
    Rep Power
    0

    Default TitledPane won't reduce size when collapsed

    Dear forum,

    I'm using a series of TitledPanes in a VBox and I want them to be expandable. When collapsed, just the title should be displayed and right below the next TitledPane. This works fine if I just put them in through SceneBuilder. Unfortunately, I need more than that - for reusability my TiledPanes have their own fxml file. Now, when collapsing a pane, it retracts its content, but it won't make space for the next pane:
    TitledPane won't reduce size when collapsed-miau.png
    In this screenshot, the center pane is collapsed. I made the borders red for more clarity.

    Here's some code:
    VBox that contains the titled panes:
    Java FX Code:
    <VBox fx:id="listView" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="311.0" prefWidth="546.0" VBox.vgrow="ALWAYS" />
    FXML for each TitledPane:
    Java FX Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <?import java.lang.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.layout.*?>
    
    <TitledPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="400.0" prefWidth="600.0" style="-fx-border-color: red;" text="PublicationBox" VBox.vgrow="ALWAYS" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.ethz.globis.box.Box4Publication">
      <content>
        <AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
             <children>
                <Label layoutX="14.0" layoutY="14.0" text="Content of PublicationBox goes here." />
             </children></AnchorPane>
      </content>
    </TitledPane>
    Code that adds the panes to the layout:
    Java FX Code:
    listView.getChildren().addAll(box1.getPane(), box2.getPane(), box3.getPane());
    (Elements are of type Box that contains the actual pane)

    Code that adds the pane to the Box object:
    Java FX Code:
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/BoxFXML/"+boxType+".fxml"));
                pane = loader.load();
                box = loader.getController();
                box.setPane(pane);
    I'm absolutely clueless. Do you have an idea why they don't collapse correctly and how I could fix that? Getting rid of the separate FXML file is not an option, since I will need many different box types later on.

    Cheers,
    Kalsan

  2. #2
    kalsan is offline Member
    Join Date
    Mar 2016
    Posts
    2
    Rep Power
    0

    Default Re: TitledPane won't reduce size when collapsed

    Found out what was wrong:

    The Box actually gets expanded by the layout around it, not by itself. When the box is large enough to hide another box, it will retract completely to display the other box.

Similar Threads

  1. Replies: 0
    Last Post: 06-24-2013, 11:56 AM
  2. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  3. How to reduce the size or avoiding out of memory error?
    By rajeshkumarmsc in forum Advanced Java
    Replies: 3
    Last Post: 08-11-2007, 10:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •