Create a list where you have the remaining buttons
List<JButton> remaining = new ArrayList( Arrays.asList( arr ) );
Each time you set a text on a button remove that button from you list
void removeButton(JButton b, String text) {
remaing.remove(b);
b.setText(text);
b.setEnabled(false);
}
then call random on the actual size
JButton b = remaining.get(r.nextInt(remaining.size()));