Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8124317

[ACCORDION] Unexpanded stays at old position, when position is changed in expandedproperty changelistener

    XMLWordPrintable

Details

    Description

      IF on an accordion an changelistener is added to the expandedpane property and in his changelistener the layoutX and layoutY Position of the accordion is changed, the unexpanded accordion stays at its old place. If the unexpanded accordion is clicked on again, an other expanded accordion appears and the unexpanded accordion disappears. To unexpand, you have to unexpand both accordions, although there is only one accorion in the java-code.

      hbox.getChildren().addAll(pc, bc);
      final Accordion ac = new Accordion();

      final TitledPane tp = new TitledPane();
      tp.setText(cantonTeacherData.getCantonAbbreviation());
      tp.setContent(hbox);
      tp.setCollapsible(true);
      ac.getPanes().add(tp);

      hbox.getChildren().remove(0);
      hbox.getChildren().remove(0);

      ac.setLayoutX(point.getX());
      ac.setLayoutY(point.getY());

      ac.expandedPaneProperty().addListener(new ChangeListener<TitledPane>() {

            @Override
            public void changed(ObservableValue<? extends TitledPane> observable, TitledPane oldValue, TitledPane newValue) {
              if (newValue != null) {
      //adds the elements, so that width of the accordion is fully expanded
                hbox.getChildren().addAll(pc, bc);
                ac.setLayoutX(0);
                ac.setLayoutY(0);
                ac.toFront();
              } else {
      //makes the unexpanded accordions width only the width of the title
                hbox.getChildren().remove(0);
                hbox.getChildren().remove(0);

                ac.setLayoutX(point.getX());
                ac.setLayoutY(point.getY());

              }
            }

          });

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: