title: How to get the correct text value from a button javafx
body: <p>I have been trying to use the name of a button in a conditional , checking if the string generated from <code>.getText()</code>is or is not equal to "New Project:" in the case below, but every time i try to run this code it always gives me a result of 'not equal' to "New Project:" which is its starting value, and runs the first block. Even at #1 where it prints of the value of this string i have copied and pasted the value printed out from this but it does not work. I have also proven by replacing the "New Project" with <code>newProjectButton.getText()</code> but this then makes the statement always use the else block. I am 99% sure that i have not made a spelling mistake on the "New Project:" bit and i am unsure of what i have done wrong here so it would be a great help if someone knew what is wrong</p>
  
  <pre><code> if(event.getTarget() == newProjectButton1){
          if(newProjectButton.getText() != "New Project:"){
              System.out.println(newProjectButton.getText());//#1
              mainSplitPane.getItems().set(1, projectLayout);
              newProjectButton.setText(project.getProjectName());
          }else{
              projectLayout = project.initLayouts(loader, projectLayout, this);
              mainSplitPane.getItems().set(1, projectLayout);
          }
  </code></pre>
  
  <p>Cheers</p>