title: How to avoid overwriting a button text in java?
body: <p>is it possible to avoid overwriting a button text. for example, in my program I have three buttons;</p>
  
  <pre><code>JButton button1 = new JButton();
  JButton button2 = new JButton();
  JButton button3 = new JButton();
  </code></pre>
  
  <p>Then I have a piece of code that randomly selects one of these buttons and write the given text/s on it, now I want is, once this code has chosen 1 button and written the text, I want it to not count this button in the next random selection or check if a certain text is already on the button then choose another button to write the text on.</p>
  
  <pre><code>String text = "text";
  JButton[] arr = {button1, button2, button3};
  Random r = new Random();
  JButton b = arr[r.nextInt(arr.length)];
  b.setText(text);
  b.setEnabled(false);
  </code></pre>