第一次從列表中選擇一個選項時,該值顯示在jtextarea上 第二次選擇選項時,該值不會更改。 有刷新選項嗎?或者更好的方法來解決這個問題?謝謝!從JOptionPane下拉列表框中選擇後無法刷新jtextarea
這裏的代碼片段:
String[] choices = {"Apple","Orange", "Pear"};
String fruit= (String) JOptionPane.showInputDialog(null, "Select Fruit:","Select Fruit", JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);
if (fruit!= null){
jtextarea.append("Name\t: " + fruit.getName() + "\n");
jtextarea.append("Color\t: " + fruit.getColor() + "\n");
}
爲了更好地幫助越早,張貼[SSCCE(http://sscce.org/)。 – 2012-04-19 22:40:10