title: Getting text value from a jButton
body: <p>So I need to simply check whether a clicked button's text is <code>"X"</code> or <code>"O"</code> (making tic tac toe)
  This code doesn't work:</p>
  
  <pre><code>if (jButton1.getText()=="X")
  </code></pre>
  
  <p>However the following code does work:</p>
  
  <pre><code>String jButText = jButton1.getText();
  if (jButText=="X")
  </code></pre>
  
  <p>Why doesn't the first bit of code work when the second does? Does it need to be something more like if (<code>jButton1.getText().toString=="X"</code>)? By the way, I don't think <code>toString</code> exists in Java. That is just somewhat the equivalent in Visual Basic, which is what I normally use to create GUIs.</p>