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

Accordion doesn't change pane correctly programmatically

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.1
    • Fix Version/s: fx2.1
    • Component/s: javafx
    • Labels:
    • Environment:

      Windows 7. JavaFX 2.1. Java 1.6 u29

      Description

      Accordions don't seem to change the expanded pane correctly programmatically. See the code example below


      package foo;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Accordion;
      import javafx.scene.control.Button;
      import javafx.scene.control.TitledPane;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;

      public class Main1 extends Application
      {

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

        private Parent getContent()
        {
          VBox box = new VBox(10);

          final TitledPane pane1 = new TitledPane();
          pane1.setText("title 1\nLong text long text");
          pane1.setContent(new Rectangle(100, 40, Color.SKYBLUE));
          TitledPane pane2 = new TitledPane();
          pane2.setText("title 2\nLong text long text");
          pane2.setContent(new Rectangle(100, 40, Color.BLUEVIOLET));
          final Accordion acc = new Accordion();
          acc.getPanes().addAll(pane1, pane2);
          acc.setExpandedPane(pane2);

          Button b = new Button("Change to Pane 1");
          b.setOnAction(new EventHandler<ActionEvent>()
          {

            @Override
            public void handle(ActionEvent arg0)
            {
              System.err.println("Changing Pane");
              acc.setExpandedPane(pane1);
            }

          });


          box.getChildren().addAll(acc, b);

          return box;
        }

        public void start(Stage stage)
        {
          stage.setX(100);
          stage.setY(100);
          stage.setWidth(300);
          stage.setHeight(300);
          Scene scene = new Scene(getContent());
          stage.setScene(scene);
          stage.show();
        }

      }

        Attachments

          Activity

            People

            • Assignee:
              kwwong Kinsley Wong
              Reporter:
              gmatthewsjfx Graham Matthews (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: