资源描述:
《java设计微波炉界面》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、补充实验1、设计如本件夹中网页显示的微波炉的界面。importjava.awt.*;importjava.awt.event.*;//importjavax.swing.*;publicclassZBfextendsPanelimplementsActionListener{staticFramef;Button[]button;finalStringa0="10";finalStringa2="牛奶";finalStringa4="清蒸鱼";finalStringa6="煮米饭";finalStringa8="煮鸡蛋";fi
2、nalStringa10="暂停";finalStringa1="20";finalStringa3="微波火力";finalStringa5="红外光波";finalStringa7="解冻";finalStringa9="电子杀菌";finalStringa11="开始";privateLabellabel1,label2,label3;publicZBf(){finalintnumbutton=12;button=newButton[numbutton];label1=newLabel();label2=newLabel
3、();label3=newLabel();button[0]=newButton(a0);button[0].setActionCommand(a0);button[2]=newButton(a2);button[2].setActionCommand(a2);button[4]=newButton(a4);button[4].setActionCommand(a4);button[6]=newButton(a6);button[6].setActionCommand(a6);button[8]=newButton(a8);b
4、utton[8].setActionCommand(a8);button[10]=newButton(a10);button[10].setActionCommand(a10);button[1]=newButton(a1);button[1].setActionCommand(a1);button[3]=newButton(a3);button[3].setActionCommand(a3);button[5]=newButton(a5);button[5].setActionCommand(a5);button[7]=ne
5、wButton(a7);button[7].setActionCommand(a7);button[9]=newButton(a9);button[9].setActionCommand(a9);button[11]=newButton(a11);button[11].setActionCommand(a11);label1.setBounds(10,40,230,50);label1.setBackground(Color.blue);label2.setBounds(10,100,230,50);label2.setBac
6、kground(Color.blue);label3.setBounds(10,160,230,50);label3.setBackground(Color.blue);f.add(label1);f.add(label2);f.add(label3);intm=220;for(inti=0;i<12;i=i+2){button[i].addActionListener(this);button[i].setBounds(10,m,110,40);m=m+60;f.add(button[i]);}m=220;for(inti=
7、1;i<12;i=i+2){button[i].addActionListener(this);button[i].setBounds(130,m,110,40);m=m+60;f.add(button[i]);}}publicvoidactionPerformed(ActionEvente){Stringcommand=e.getActionCommand();if(command==a0
8、
9、command==a1)label1.setText("处理"+command+"分钟");elseif(command==a2
10、
11、c
12、ommand==a4
13、
14、command==a6
15、
16、command==a8)label2.setText("选择的食物为:"+command);elselabel3.setText(""+command);}publicstaticvoidmain(String[]args){