title: JavaFX: How to set a TiteledPane selected/opened by default
body: <p>I am working on a project using java and <strong>javaFX</strong>, i need to know if there is a way to have the first <code>TiteledPane</code>  in the <code>Accordion</code> opened <strong>by default</strong>..</p>
  <p>I mean when the stage is <strong>loaded</strong>, the first <code>TiteledPane</code> is selected and its content showed <strong>without any user's intervention</strong>. i tried all suggested methods but no one look like what i want. As i see also no described one in the official documentation or given in this site or other is like.</p>
  <hr />
  <p><strong>IN ADDITION:</strong></p>
  <p>here is my approach:(Code java and FXML)</p>
  <pre><code>@FXML
  private Accordion accord_pane;
  @FXML
  private TitledPane pane_ara,pane_sci,pane_soc,pane_art,pane_spo,pane_fra,pane_ang;
  
  ...
  
  pane_ara.setText(&quot;TitledPane A&quot;);
  pane_sci.setText(&quot;TitledPane B&quot;);
  
  accord_pane.setExpandedPane(pane_ara);
  </code></pre>
  <hr />
  <pre><code>               &lt;Accordion fx:id=&quot;accord_pane&quot; layoutX=&quot;20.0&quot; layoutY=&quot;100.0&quot; prefHeight=&quot;400.0&quot; prefWidth=&quot;680.0&quot;&gt;
                    &lt;panes&gt;
                      &lt;TitledPane fx:id=&quot;pane_ara&quot; animated=&quot;false&quot;&gt;
                           &lt;content&gt;
                              &lt;Pane prefHeight=&quot;200.0&quot; prefWidth=&quot;200.0&quot;&gt;
                                 &lt;children&gt;
                                    &lt;ImageView fx:id=&quot;img_unit_ara&quot; fitHeight=&quot;250.0&quot; fitWidth=&quot;650.0&quot; layoutX=&quot;15.0&quot; layoutY=&quot;15.0&quot; pickOnBounds=&quot;true&quot; preserveRatio=&quot;true&quot;&gt;
                                       &lt;image&gt;
                                          &lt;Image url=&quot;@temp_5.png&quot; /&gt;
                                       &lt;/image&gt;
                                    &lt;/ImageView&gt;
                                 &lt;/children&gt;
                              &lt;/Pane&gt;
                           &lt;/content&gt;
                      &lt;/TitledPane&gt;
                        &lt;TitledPane fx:id=&quot;pane_sci&quot; animated=&quot;false&quot;&gt;
                           &lt;content&gt;
                              &lt;Pane prefHeight=&quot;200.0&quot; prefWidth=&quot;200.0&quot;&gt;
                                 &lt;children&gt;
                                    &lt;ImageView fx:id=&quot;img_unit_sci&quot; fitHeight=&quot;190.0&quot; fitWidth=&quot;650.0&quot; layoutX=&quot;15.0&quot; layoutY=&quot;15.0&quot; pickOnBounds=&quot;true&quot; preserveRatio=&quot;true&quot;&gt;
                                       &lt;image&gt;
                                          &lt;Image url=&quot;@temp_3.png&quot; /&gt;
                                       &lt;/image&gt;
                                    &lt;/ImageView&gt;
                                 &lt;/children&gt;
                              &lt;/Pane&gt;
                           &lt;/content&gt;
                        &lt;/TitledPane&gt;
                       &lt;/panes&gt;
                     &lt;/Accordion&gt;
  </code></pre>
  <p>here is the exception:</p>
  <pre><code>javafx.fxml.LoadException: 
  /C:/Users/Malek%20Boubakri/Google%20Drive/workspace/Sirat/bin/vue/Enseignant.fxml
  at javafx.fxml.FXMLLoader.constructLoadException(Unknown Source)
  at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
  at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
  at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
  at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
  at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
  at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
  at javafx.fxml.FXMLLoader.loadImpl(Unknown Source)
  at javafx.fxml.FXMLLoader.load(Unknown Source)
  at vue.Enseignant.start(Enseignant.java:18)
  at vue.Index.stageCtrlHandler(Index.java:85)
  at controleur.MenuCtrl.click_btn(MenuCtrl.java:69)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at sun.reflect.misc.Trampoline.invoke(Unknown Source)
  at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
  at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
  at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
  at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
  at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
  at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
  at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
  at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
  at javafx.event.Event.fireEvent(Unknown Source)
  at javafx.scene.Scene$ClickGenerator.postProcess(Unknown Source)
  at javafx.scene.Scene$ClickGenerator.access$8100(Unknown Source)
  at javafx.scene.Scene$MouseHandler.process(Unknown Source)
  at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
  at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
  at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$350(Unknown Source)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler$$Lambda$165/775736639.get(Unknown Source)
  at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
  at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
  at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
  at com.sun.glass.ui.View.notifyMouse(Unknown Source)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
  at com.sun.glass.ui.win.WinApplication$$Lambda$36/2117255219.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.NullPointerException
      at controleur.EnsCtrl.initialize(EnsCtrl.java:301)
      ... 54 more
  </code></pre>
  <p>here is the text from documentation that i lean on.</p>
  <blockquote>
  <p><strong>public final void setExpandedPane(TitledPane value)</strong></p>
  <p>The expanded TitledPane that is currently visible. While it is
  technically possible to set the expanded pane to a value that is not
  in getPanes(), doing so will be treated by the skin as if expandedPane
  is null. If a pane is set as the expanded pane, and is subsequently
  removed from getPanes(), then expanded pane will be set to null, if
  possible. (This will not be possible if you have manually bound the
  expanded pane to some value, for example).</p>
  </blockquote>
  <p>If any thing is not clear please just comment. Any suggestion will be helpful..Thanks</p>