java applet choice_Java Applet java.awt.Choice Add Item第二次不工作(Java Applet java.awt.Choice Add Item n...

I am writing an applet which contains a panel (PanelCondition) with a java.awt.choice dropdown. http://docs.oracle.com/javase/7/docs/api/java/awt/Choice.html

public class PanelCondition extends Panel

{

Choice choiceCond = new Choice();

public PanelCondition(bool isGood)

{

setCond(isGood);

}

private void setCond(boolean isGood)

{

condCode = getCondItems(isGood);

this.choiceCond.removeAll();

for (int i=0; i < condCode.length; i++)

{

this.choiceCond.addItem(condCode[i]);

}

this.choiceCond.repaint();

}

...

}

The PanelCondition is included in a java.awt.Frame

public class FrameExample extends Frame

{

PanelCondition cond;

private void setCond(bool isGood)

{

cond = new PanelCondition(isGood)

this.add(orderCond,...)

...

}

}

When the FrameExample.setCond() is called first time (isGood=true), the correct items are added to the dropdownlist. However if I call the setCond() the second time (isGood=false), the dropdownlist items don't have any changes.

I have tried to call this.choiceCond.validate() or this.choiceCond.repaint, but it still doesn't work.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值