JRadioButton maleButton = new JRadioButton( "Male" ); maleButton.setActionCommand( maleButton.getText() );