title: Return the actual value from a toggleGroup javafx
body: <p>I have a ToggleGroup of buttons which can be 3 buttons with the togglename choose an answers or 2 buttons with the togglename true or false. As a matter of fact the togglegroup contains buttons which correspond to asnwers (from questions to a quiz game I made in javafx). On the click event I want to locate which buttons was pressed and returned the correspondant value during the actionlistener.</p>
  
  <p>My code is the following:`</p>
  
  <pre><code>groupAnswerQ = new ToggleGroup();
  
  class MyChooseAnswerButton extends ToggleButton {
       public MyChooseAnswerButton() {
          setToggleGroup(groupAnswerQ);
          setWrapText(true);
       }
  }
  
  SanswerButton1 = new MyChooseAnswerButton();
  SanswerButton2 = new MyChooseAnswerButton();
  SanswerButton3 = new MyChooseAnswerButton();
  
  groupAnswerQ.selectedToggleProperty().addListener(new ChangeListener&lt;Toggle&gt;() {
    public void changed(ObservableValue&lt;? extends Toggle&gt; ov, Toggle toggle, Toggle new_toggle) {
       if (new_toggle != null) {
                  textAnswerQ = (String) groupAnswerQ.getSelectedToggle().getUserData();
                  System.out.println("textAnswerQ : " + textAnswerQ);
      }
    }
  });`
  </code></pre>
  
  <p>This is for the case of choose an answer (for the true or false is the similar code). My problem is that when the event is detected the textAnswerQ returns always null even when the new_toggle is not null. What am I doing wrong here?</p>