Search code examples
javaswingjradiobutton

How come my JRadioButtons labels are "..." and not text I want?


I don't know why each button isn't displaying the text i want, and why it is displaying "..."

ButtonGroup operations = new ButtonGroup(); 

 JRadioButton[] buttons = new JRadioButton[2]; 

 String[] buttonLabels = {"Male", "Female"}; 

 for (int i=0; i<2; i++) { 
     buttons[i] = new JRadioButton(buttonLabels[i], true); 

     buttons[i].setLocation(400 + (i * 50) , 170); 
     buttons[i].setSize(35, 30); 

     add(buttons[i]); 
     operations.add(buttons[i]); 


 }

This IS what Im getting

I want button[0] to say Male and button1 to say Female


Solution

  • This happens when there isn't enough space for the whole text to display. You can try placing them under each other or stretching the width a little.