中国Java开发网 中国Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» 中国Java开发网 » Java GUI 设计  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
话题被移动
该话题已被移动 - 九佰 , 2009-11-27 14:56
如果您尚不清楚该话题被移动的原因,请参考论坛规则以及本版公告或者联系本版版主。
作者 java选择结构无法实现
advancing





发贴: 1
积分: 0
于 2009-11-05 21:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
private void JComboBoxMonthItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:

leap=YEAR%4==0&&YEAR%100!=0||YEAR%400==0;
month=(String)JComboBoxMonth.getSelectedItem();
if(month.startsWith("4")||month.startsWith("6")||month.startsWith("9")||month.startsWith("11"))
{
JComboBoxDay.removeItem("31");
}

else if((!leap)&&month=="2")
{
JComboBoxDay.removeAllItems();

JComboBoxDay.addItem("26");
JComboBoxDay.addItem("27");
JComboBoxDay.addItem("28");
JComboBoxDay.addItem("29");
JComboBoxDay.addItem("30");
JComboBoxDay.addItem("31");
JComboBoxDay.removeItem("31");
JComboBoxDay.removeItem("30");
JComboBoxDay.removeItem("29");
}
else if(month.startsWith("1")||month.startsWith("3")||month.startsWith("5")||month.startsWith("7")||month.startsWith("8")||month.startsWith("10")||month.startsWith("12"))
{
JComboBoxDay.removeAllItems();

JComboBoxDay.addItem("26");
JComboBoxDay.addItem("27");
JComboBoxDay.addItem("28");
JComboBoxDay.addItem("29");
JComboBoxDay.addItem("30");
JComboBoxDay.addItem("31");

}
else if((leap)&&month=="2")
{
JComboBoxDay.removeAllItems();

JComboBoxDay.addItem("26");
JComboBoxDay.addItem("27");
JComboBoxDay.addItem("28");
JComboBoxDay.addItem("29");
JComboBoxDay.addItem("30");
JComboBoxDay.addItem("31");
JComboBoxDay.removeItem("31");
JComboBoxDay.removeItem("30");

}
}

private void JComboBoxYearItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
year=(String)JComboBoxYear.getSelectedItem();
YEAR=Integer.parseInt(year);
}

无论YEAR取什么值都执行 else if((leap)&&month=="2")分支
当注释 else if((leap)&&month=="2")分支时执行else if((!leap)&&month=="2")分支




话题树型展开
人气 标题 作者 字数 发贴时间
7460 java选择结构无法实现 advancing 2288 2009-11-05 21:53

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2017 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号
客服电话 0592-8750026    客服信箱 714923@qq.com    客服QQ 714923