




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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年环境保护督察员考试试题及答案解析
- 四季的公园400字7篇范文
- 爱在邻里之间900字7篇
- 出生及全程职业生涯证明书(6篇)
- 这就是我作文900字(10篇)
- 高一(上)英语阶段检测卷二
- 小学《自然现象观察》科学活动教案
- 我周围的环境500字7篇
- 周末趣事周记形式分享故事8篇
- 《语数外三位一体英语语法突破教案》
- 村文书考试题及答案
- 电气技术及其应用试题及答案
- 大数据驱动的人才招聘分析-洞察阐释
- 2025年护理三基知识必考重点题库及答案(共720题)
- 中国妊娠期糖尿病母儿共同管理指南(2024版)核心要点解读
- 2025届四川省眉山市百坡初级中学八下数学期末复习检测模拟试题含解析
- 大数据在区域经济学中的应用研究-洞察阐释
- 《宠物保健品营销策略》课件
- 2025春季学期河南电大本科补修课《民法学#》一平台无纸化考试(作业练习+我要考试)试题及答案
- 民兵理论考试试题及答案
- 公寓管理考试试题及答案
评论
0/150
提交评论