当前位置: 技术问答>java相关
J2ME里的ITEM中的ItemStateListener怎么使用?在线等待
来源: 互联网 发布时间:2015-06-23
本文导语: RT | 不知道你是不是用的jdk1.4 我在jdk1.2 中没有 itemStateListener. 给你一个 itemStateChanged 的例子 If you use a ChoiceControl, you would use the itemStateChanged event and the body of the event-handling method...
RT
|
不知道你是不是用的jdk1.4
我在jdk1.2 中没有 itemStateListener.
给你一个 itemStateChanged 的例子
If you use a ChoiceControl, you would use the itemStateChanged event and the body of the
event-handling method would look like this:
void choiceControl1_itemStateChanged(java.awt.event.ItemEvent e) {
if (choiceControl1.getSelectedItem()== "One") {
cardLayout1.show(bevelPanel2, "bevelPanel3");
}
else if (choiceControl1.getSelectedItem()== "Two") {
cardLayout1.show(bevelPanel2, "bevelPanel4");
}
else if (choiceControl1.getSelectedItem()== "Three") {
cardLayout1.show(bevelPanel2, "bevelPanel5");
}
}
我在jdk1.2 中没有 itemStateListener.
给你一个 itemStateChanged 的例子
If you use a ChoiceControl, you would use the itemStateChanged event and the body of the
event-handling method would look like this:
void choiceControl1_itemStateChanged(java.awt.event.ItemEvent e) {
if (choiceControl1.getSelectedItem()== "One") {
cardLayout1.show(bevelPanel2, "bevelPanel3");
}
else if (choiceControl1.getSelectedItem()== "Two") {
cardLayout1.show(bevelPanel2, "bevelPanel4");
}
else if (choiceControl1.getSelectedItem()== "Three") {
cardLayout1.show(bevelPanel2, "bevelPanel5");
}
}
|
一般item是用Form的append方法添加到一个form中的(用于多个项目显示)
使用时对form调用setItemStateListener就可以了。
自己实现一个ItemStateListener.
使用时对form调用setItemStateListener就可以了。
自己实现一个ItemStateListener.
|
比如form.setItemListener(this);
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。