RadioButton 到 TextArea 问题
RadioButton to TextArea Issue
我无法从无线电按钮中获取文本以显示为文本区域时显示。只能得到一个真值或假值。下面的代码是我遇到问题的地方。如果有任何建议,我将不胜感激。
jTextArea2.setText(String.valueOf("Mixed Flavors:" + jRadioButton1.isSelected() + jRadioButton2.isSelected()
+ jRadioButton3.isSelected() + jRadioButton4.isSelected()));
我无法从单选按钮中获取文本以显示为文本区域,我只是希望您想尝试
之类的东西
if( jRadioButton1.isSelected() )
jTextArea2.setText( String.valueOf("BLA") + jRadioButton1.getText() );
if( jRadioButton2.isSelected() )
jTextArea2.setText( String.valueOf("BLA") + jRadioButton2.getText() );
if( jRadioButton3.isSelected() )
jTextArea2.setText( String.valueOf("BLA") + jRadioButton3.getText() );
if( jRadioButton4.isSelected() )
jTextArea2.setText( String.valueOf("BLA") + jRadioButton4.getText() );
获取文本您必须在单选按钮上使用 getText()
。也没有必要使用 String.valueOf()
因为你试图在 TextArea 中设置的整个东西将变成一个字符串。
jTextArea2.setText("Mixed Flavors:" + jRadioButton1.getText() + ":" +
jRadioButton1.isSelected() + " , " + jRadioButton2.getText() + ":" +
jRadioButton2.isSelected() + " , "+ jRadioButton3.getText() + ":" +
jRadioButton3.isSelected() + " , " + jRadioButton4.getText() + ":" +
jRadioButton4.isSelected());
我无法从无线电按钮中获取文本以显示为文本区域时显示。只能得到一个真值或假值。下面的代码是我遇到问题的地方。如果有任何建议,我将不胜感激。
jTextArea2.setText(String.valueOf("Mixed Flavors:" + jRadioButton1.isSelected() + jRadioButton2.isSelected()
+ jRadioButton3.isSelected() + jRadioButton4.isSelected()));
我无法从单选按钮中获取文本以显示为文本区域,我只是希望您想尝试
之类的东西if( jRadioButton1.isSelected() )
jTextArea2.setText( String.valueOf("BLA") + jRadioButton1.getText() );
if( jRadioButton2.isSelected() )
jTextArea2.setText( String.valueOf("BLA") + jRadioButton2.getText() );
if( jRadioButton3.isSelected() )
jTextArea2.setText( String.valueOf("BLA") + jRadioButton3.getText() );
if( jRadioButton4.isSelected() )
jTextArea2.setText( String.valueOf("BLA") + jRadioButton4.getText() );
获取文本您必须在单选按钮上使用 getText()
。也没有必要使用 String.valueOf()
因为你试图在 TextArea 中设置的整个东西将变成一个字符串。
jTextArea2.setText("Mixed Flavors:" + jRadioButton1.getText() + ":" +
jRadioButton1.isSelected() + " , " + jRadioButton2.getText() + ":" +
jRadioButton2.isSelected() + " , "+ jRadioButton3.getText() + ":" +
jRadioButton3.isSelected() + " , " + jRadioButton4.getText() + ":" +
jRadioButton4.isSelected());