Hi,
When I set "setManaged(false)" and "setVisible(false)" on a TitledPane within a Accordion it wont visualy remove from the accordion as supposed.
Somehow its like just setting "setVisible(false)" (see Image).
http://img28.imageshack.us/img28/6821/titledpane.png
here is the code for the fxml (this fxml wont work under JavaFX 2.0, because I removed Nodes covered by @DefaultProperty in 2.1)
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox xmlns:fx="http://javafx.com/fxml" fx:controller="Controller">
<MenuBar>
<Menu text="show">
<items>
<CheckMenuItem text="Accordion" selected="true" fx:id="toggleAccordion" />
<CheckMenuItem text="first" selected="true" fx:id="toggleFirst" />
<CheckMenuItem text="second" selected="true" onAction="#handleToggleSecond" />
</items>
</Menu>
</MenuBar>
<Accordion fx:id="accordion">
<panes>
<TitledPane text="first" fx:id="first">
<content>
<Label text="test" />
</content>
</TitledPane>
<TitledPane text="second" fx:id="second">
<content>
<Label text="test2" />
</content>
</TitledPane>
<TitledPane text="last">
<content>
<Label text="last" />
</content>
</TitledPane>
</panes>
</Accordion>
</VBox>
And here is my Controller:
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Accordion;
import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.TitledPane;
public class Controller implements Initializable {
@FXML
private CheckMenuItem toggleAccordion;
@FXML
private CheckMenuItem toggleFirst;
@FXML
private Accordion accordion;
@FXML
private TitledPane first;
@FXML
private TitledPane second;
@Override
public void initialize(URL location, ResourceBundle resources) {
accordion.managedProperty().bindBidirectional(toggleAccordion.selectedProperty());
accordion.visibleProperty().bindBidirectional(toggleAccordion.selectedProperty());
first.managedProperty().bindBidirectional(toggleFirst.selectedProperty());
first.visibleProperty().bindBidirectional(toggleFirst.selectedProperty());
}
public void handleToggleSecond(ActionEvent event) {
Object source = event.getSource();
if (source instanceof CheckMenuItem) {
second.setManaged(((CheckMenuItem) source).isSelected());
second.setVisible(((CheckMenuItem) source).isSelected());
}
}
}
As you can see I tryed some different ways to set the "setManaged" ... once with bindbidirectional and once with an ActionEvent.
I am pretty sure, that this code (the ActionEvent) was working in JavaFX 2.0.
Is it a bad idea to set setManaged on a TitledPane?
Can you reproduce this error?
Is it a bug?
Thanks for any suggestions :)