求一java小程序,,像计算器,小游戏,或者什么的。
2019-03-12 17:02:19
微信公开课小程序热门讨论「求一java小程序,,像计算器,小游戏,或者什么的。」最新回复-publicclassTest{doubleresult=0;booleanstart=true;StringlastCommand=+;//最终的符号Fontfont=newFont(null,Font.PLAIN,25);Fontfont2=newFont(null,Font.PLAIN,20);JFrameframe=newJFrame(简易计算器);JPanelpanel1=newJPanel();JPanelpanel2=newJPanel();JPanelpanel3=newJPanel();JPanelpanel4=newJPanel();JPanelpanel5=newJPanel();JTextFieldtext=newJTextField();JButtonb0=newJButton(0);JButtonb1=newJButton(1);JButtonb2=newJButton(2);JButtonb3=newJButton(3);JButtonb4=newJButton(4);JButtonb5=newJButton(5);JButtonb6=newJButton(6);JButtonb7=newJButton(7);JButtonb8=newJButton(8);JButtonb9=newJButton(9);JButtona1=newJButton(+);JButtona2=newJButton();JButtona3=newJButton(*);JButtona4=newJButton(/);JButtona5=newJButton(=);JButtona6=newJButton(.);JButtona7=newJButton(清零);JButtona8=newJButton(取消);JButtona9=newJButton(sqrt);JButtona10=newJButton(+/);publicvoidset(){frame.setSize(400,350);frame.setLayout(newGridLayout(5,1,2,2));panel1.setBackground(Color.black);panel2.setBackground(Color.red);panel3.setBackground(Color.blue);panel4.setBackground(Color.green);panel5.setBackground(Color.yellow);panel1.setLayout(newBorderLayout());panel1.add(text,Center);panel2.setLayout(newGridLayout(1,5,1,1));panel3.setLayout(newGridLayout(1,5,1,1));panel4.setLayout(newGridLayout(1,5,1,1));panel5.setLayout(newGridLayout(1,5,1,1));text.setHorizontalAlignment(JTextField.RIGHT);b0.setFont(font);b1.setFont(font);b2.setFont(font);b3.setFont(font);b4.setFont(font);b5.setFont(font);b6.setFont(font);b7.setFont(font);b8.setFont(font);b9.setFont(font);a1.setFont(font);a2.setFont(font);a3.setFont(font);a4.setFont(font);a5.setFont(font);a6.setFont(font);a7.setFont(font2);a8.setFont(font2);a9.setFont(font);a10.setFont(font);frame.setVisible(true);}publicvoidaddComponent(){panel2.add(b7);panel2.add(b8);panel2.add(b9);panel2.add(a4);panel2.add(a7);panel3.add(b4);panel3.add(b5);panel3.add(b6);panel3.add(a3);panel3.add(a8);panel4.add(b1);panel4.add(b2);panel4.add(b3);panel4.add(a2);panel4.add(a9);panel5.add(b0);panel5.add(a10);panel5.add(a6);panel5.add(a1);panel5.add(a5);frame.add(panel1);frame.add(panel2);frame.add(panel3);frame.add(panel4);frame.add(panel5);}publicvoidaddListener(){b0.addActionListener(newInsertAction());b1.addActionListener(newInsertAction());b2.addActionListener(newInsertAction());b3.addActionListener(newInsertAction());b4.addActionListener(newInsertAction());b5.addActionListener(newInsertAction());b6.addActionListener(newInsertAction());b7.addActionListener(newInsertAction());b8.addActionListener(newInsertAction());b9.addActionListener(newInsertAction());a1.addActionListener(newCommandAction());a2.addActionListener(newCommandAction());a3.addActionListener(newCommandAction());a4.addActionListener(newCommandAction());a5.addActionListener(newCommandAction());a6.addActionListener(newInsertAction());a7.addActionListener(newInsertAction());a8.addActionListener(newInsertAction());a9.addActionListener(newCommandAction());a10.addActionListener(newInsertAction());}publicvoidgo(){this.set();this.addComponent();this.addListener();}classInsertActionimplementsActionListener{publicvoidactionPerformed(ActionEventevent1){Stringinput=event1.getActionCommand();if(start){text.setText();start=false;if(input.equals(+/))text.setText(text.getText()+);}if(!input.equals(+/)){if(input.equals(取消)){Stringstr=text.getText();if(str.length()0)text.setText(str.substring(0,str.length()1));}elseif(input.equals(清零)){text.setText(0);lastCommand=+;start=true;result=0;}elsetext.setText(text.getText()+input);}}}classCommandActionimplementsActionListener{publicvoidactionPerformed(ActionEventevent2){Stringcommand=event2.getActionCommand();if(start){lastCommand=command;}else{//Doubledata=newDouble(text.getText());calculator(Double.parseDouble(text.getText()));lastCommand=command;start=true;}}}publicvoidcalculator(doublex){if(lastCommand.equals(+))result+=x;elseif(lastCommand.equals())result=x;elseif(lastCommand.equals(*))result*=x;elseif(lastCommand.equals(/))result/=x;elseif(lastCommand.equals(=))result=x;elseif(lastCommand.equals(sqrt))result=Math.sqrt(x);text.setText(+result);}publicstaticvoidmain(String[]args){Testa=newTest();a.go();}}
http://wenku.baidu.com/view/1e8851de6bec0975f565e213.html五子棋 更多有关「求一java小程序,,像计算器,小游戏,或者什么的。」的疑问请扫码关注微信公开课+小程序!
http://wenku.baidu.com/view/1e8851de6bec0975f565e213.html五子棋 更多有关「求一java小程序,,像计算器,小游戏,或者什么的。」的疑问请扫码关注微信公开课+小程序!
标签:微信公开课,小程序
「求一java小程序,,像计算器,小游戏,或者什么的。」热议话题订阅
方法1:微信扫描微信公开课小程序码即可订阅热议话题「求一java小程序,,像计算器,小游戏,或者什么的。」
方法2:微信搜索微信公开课小程序名称进入,即可订阅热议话题「求一java小程序,,像计算器,小游戏,或者什么的。」
方法3:微信网页访问即速商店,长按识别微信公开课小程序码即可订阅热议话题「求一java小程序,,像计算器,小游戏,或者什么的。」
微信公开课小程序热议话题「求一java小程序,,像计算器,小游戏,或者什么的。」由微信公开课原创摘录于微信小程序商店shop.jisuapp.cn,转载请注明出处。
微信公开课热议话题「求一java小程序,,像计算器,小游戏,或者什么的。」由微信公开课开发者向微信用户提供,并对本服务内容、数据资料及其运营行为等真实性、合法性及有效性承担全部责任。
微信公开课小程序
更新时间:2019-03-12 17:02:19
>
__methodCallerx27;ofundefined
>-404011cloudfunctionexecutionerror
>,请补充选择商家自营-预付卡销售-发行方类目,并在基础信息处申请该类目,通过
>:host在模拟器中显示无效
>:请在小程序服务页面上架正式(非测试)内容或商品后重新提交审核
>.net 微信小程序 上传图片
>'setTimeout'的问题
>‘三朵里熙SPA主题减压空间’为什么搜索关键词‘三朵里‘搜不到
>‘扫普通链接二维码打开小程序‘中设置为体验版,扫码打开是线上版本
>“cloudfunctions**indexjs”gitignore
>“NO ULINK DEVICE FOUND”是怎么回事
>“万马掌上校园”的类目审核
>“上线了”公司开发的微信小程序怎么样?
>“产品是否一定需要条形码”
>