




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
import java.awt.*;import java.awt.event.*;import javax.swing.BoxLayout;public class H5 /* param args*/class stateString prevous_in;String current_in;String prevous_out;String current_out;String prevous_i_s;String prevous_o_s;String current_o_s;String current_i_s;public state()prevous_in=;current_in=; prevous_out=; current_out=; prevous_i_s=; prevous_o_s=; current_o_s=; current_i_s=;state st=new state();Frame f=new Frame(张三);Panel ptop=new Panel();Panel pbot=new Panel();Label label1=new Label(数据转换,FlowLayout.CENTER);Label label2=new Label(result,FlowLayout.CENTER);TextField tfin=new TextField(20);TextField tfout=new TextField(20);Button ok=new Button(确定);Button exit=new Button(exit);Panel pcen=new Panel();CheckboxGroup cbg1=new CheckboxGroup();CheckboxGroup cbg2=new CheckboxGroup();Checkbox in2=new Checkbox(2,cbg1,false);Checkbox in8=new Checkbox(8,cbg1,false);Checkbox in10=new Checkbox(10,cbg1,true);Checkbox in16=new Checkbox(16,cbg1,false);Checkbox out2=new Checkbox(2,cbg2,false);Checkbox out8=new Checkbox(8,cbg2,false);Checkbox out10=new Checkbox(10,cbg2,true);Checkbox out16=new Checkbox(16,cbg2,false);Panel pinshuzhi=new Panel();Panel poutshuzhi=new Panel();B_e_lis bel=new B_e_lis();B_OK_lis bokl=new B_OK_lis();int temint=0;MenuBar mb=new MenuBar();Menu edit=new Menu(编辑);MenuItem back=new MenuItem(回看,new MenuShortcut(KeyEvent.VK_B);MenuItem recover=new MenuItem(恢复,new MenuShortcut(KeyEvent.VK_R);MenuItem quit=new MenuItem(退出,new MenuShortcut(KeyEvent.VK_X);QuitListener qlisten=new QuitListener();String prevous=;String current=;String prevous_s=;String current_s=;public void init()System.out.println(quit.getLabel();f.addWindowListener(new Mylistener();/f.setBounds(0,0,400,400);ptop.setLayout(new BoxLayout(ptop,BoxLayout.Y_AXIS);ptop.add(label1);/ptop.add(tf);pbot.add(ok);exit.addActionListener(bel);ok.addActionListener(bokl);pbot.add(exit);pinshuzhi.add(in2);pinshuzhi.add(in8);pinshuzhi.add(in10);pinshuzhi.add(in16); poutshuzhi.add(out2);poutshuzhi.add(out8);poutshuzhi.add(out10); poutshuzhi.add(out16);pcen.setLayout(new BoxLayout(pcen,BoxLayout.Y_AXIS);pcen.add(tfin);pcen.add(pinshuzhi);pcen.add(label2);pcen.add(poutshuzhi);pcen.add(tfout);f.add(ptop,BorderLayout.NORTH);f.add(pbot,BorderLayout.SOUTH);f.add(pcen,BorderLayout.CENTER);quit.addActionListener(qlisten);edit.addActionListener(qlisten);edit.add(back);edit.add(recover);edit.add(quit);mb.add(edit);f.setMenuBar(mb);f.setBounds(50, 50, 400, 300);/f.pack();f.setVisible(true); class Mylistener extends WindowAdapterpublic void windowClosing(WindowEvent e)System.exit(0); class QuitListener implements ActionListenerpublic void actionPerformed(ActionEvent e)System.out.println(menu);String s=e.getActionCommand();if(s.equals(退出) System.out.println(quit);System.exit(0);if(s.equals(回看)tfout.setText(st.prevous_out);tfin.setText(st.prevous_in);if(in2.getLabel().equals(st.prevous_i_s) in2.setState(true);if(in8.getLabel().equals(st.prevous_i_s) in8.setState(true);if(in10.getLabel().equals(st.prevous_i_s) in10.setState(true);if(in16.getLabel().equals(st.prevous_i_s) in16.setState(true);if(s.equals(恢复)tfout.setText(st.current_out);tfin.setText(st.current_in);if(out2.getLabel().equals(st.current_i_s) out2.setState(true);if(out8.getLabel().equals(st.current_i_s) out8.setState(true);if(out10.getLabel().equals(st.current_i_s) out10.setState(true);if(out16.getLabel().equals(st.current_i_s) out16.setState(true); private int get_int(char c)int tem=-1;if(c=0 & c=A & c=a & c=0 & c=0 & c=0 & c=0 & c=a & c=A & c=F) return true;return false;class B_OK_lis implements ActionListenerpublic void actionPerformed(ActionEvent e)st.prevous_i_s=st.current_i_s;st.prevous_in=st.current_in;st.prevous_o_s=st.current_o_s;st.prevous_out=st.current_out;temint=0;System.out.println(ok);String sin=tfin.getText();String sout=null;char tem;tem=new charsin.length();tem=sin.toCharArray();/for(int j=0;jsin.length();j+)/int i=Integer.parseInt(s);/boolean ss;/ss=in2.getState();/System.out.println(ss);/int i=Integer./tfout.setText(sout);/for(int i=0;isin.length();i+)/System.out.println(temi);/System.out.println(sin.length();boolean flag=true;if(in2.getState()=true)st.current_i_s=in2.getLabel();for(int i=0;isin.length();i+)tryif(check_2(temi)=false) throw new Exception(wrong input);else temint=temint*2+get_int(temi);catch(Exception ea)sout=input wrong+temi;flag=false;break; if(in10.getState()=true)st.current_i_s=in10.getLabel();for(int i=0;isin.length();i+)tryif (check_10(temi)=false) throw new Exception(wrong input); else temint=temint*10+get_int(temi); catch(Exception ea)sout=input wrong+temi;flag=false;break;if(in8.getState()=true)st.current_i_s=in8.getLabel();for(int i=0;isin.length();i+)tryif(check_8(temi)=false) throw new Exception(wrong input);else temint=temint*8+get_int(temi);catch(Exception ea)sout=input wrong+temi; flag=false;break;if(in16.getState()=true)st.current_i_s=in16.getLabel();for(int i=0;isin.length();i+)tryif(check_16(temi)=false)throw new Exception(wrong input);else temint=temint*16+get_int(temi);catch(Exception ea)sout=input wrong+temi; flag=false;break;if(out2.getState()=true & flag)st.current_o_s=out2.getLabel(); sout=Integer.toBinaryString(temint);if(out8.getState()=true & flag) st.current_o_s=out8.getLabel();sout=Integer.toOctalString(temint); if(out10.getState()=true & flag)st.current_o_s=out10.getLabel();sout=Integer.toString(temint);if(out16.getState()=true & flag)st.current_o_s=out16.getLabel(); sout=Integer.toHexString(temint);st.current_in=s
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年健康知识竞赛试题库(答案+解析)
- 全屋装修案例讲解
- 混凝土结构检测技术课件
- 人工呼吸急救讲解图解
- 千方百计课程讲解
- 欧美时尚服装产业洞察
- 电商客户细分与个性化标签系统创新创业项目商业计划书
- 知识分享音频平台创新创业项目商业计划书
- 智能会议记录助手创新创业项目商业计划书
- 智能家庭娱乐控制中心创新创业项目商业计划书
- 《租船问题》教学设计及说课稿
- 儿童之家实施可行性方案
- 无痛胃肠镜全麻知情同意书
- 心衰患者的容量管理中国专家共识-共识解读
- 教师个人简历表格
- 文松宋晓峰小品《非诚不找》奇葩男女来相亲金句不断台词剧本完整版
- 高等院校毕业生转正定级审批表-6
- 劳务合同模板电子下载
- 容错纠错机制运行过程中存在的问题及对策研究
- 红星照耀中国选择题及答案50道
- 氯甲烷泄露应急预案
评论
0/150
提交评论