定点整数二进制运算由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“在定点二进制运算器中”。
口令:123
package xiangmu;/** * * @author pc */ public cla Xiangmu {
/**
* @param args the command line arguments
*/
public static void main(String[] args){
Window win = new Window();
}
}
package xiangmu;/** * * @author pc */ import java.lang.Object;import java.awt.*;import java.awt.event.*;import javax.swing.*;cla Window extends JFrame implements ActionListener {
JMenuBar menubar;//菜单条
JMenu menu1,menu2,menu3,menu4;//菜单栏
JMenuItem item1,item2,item3,item4;//菜单项
JButton queren;
JLabel koul,bti;
JPanel p1,p2;
JPawordField mima;
String txt=“123”;
int cishu=0;public Window(){
this.setBounds(400, 100, 600, 400);
this.setResizable(false);//窗口大小不许改变
caidan();
this.setLayout(null);
koul = new JLabel(“输入口令:”);
koul.setBounds(150, 100, 150, 100);
mima = new JPawordField(10);
mima.setBounds(250, 140, 150, 20);
koul.setFont(new Font(“宋体”,Font.BOLD,15));
bti =new JLabel(“计算机组成原理算法实现
(二)”);
bti.setFont(new Font(“宋体”,Font.BOLD,25));//改变字体大小
bti.setBounds(130,-20, 380, 210);
queren = new JButton(“确定”);
queren.setFont(new Font(“宋体”,Font.BOLD,15));
queren.setBounds(270, 200, 100, 30);
item1.setEnabled(false);
//菜单访问权设置
item2.setEnabled(false);
item3.setEnabled(false);
item4.setEnabled(false);
item1.addActionListener(this);//监听
item2.addActionListener(this);
item3.addActionListener(this);
item4.addActionListener(this);
queren.addActionListener(this);
this.add(queren);
this.add(mima);
this.add(koul);
this.add(bti,“Center”);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}
void caidan(){
menubar = new JMenuBar();
menu1 = new JMenu(“定点整数机器表示”);
menu2 = new JMenu(“定点整数变形补码加减法”);
menu3 = new JMenu(“定点整数原码乘法”);
menu4 = new JMenu(“浮点加减法”);
menubar.add(menu1);
menubar.add(menu2);
menubar.add(menu3);
menubar.add(menu4);
item1 = new JMenuItem(“定点整数机器表示”);
item2 = new JMenuItem(“定点整数变形补码加减法”);
item3 = new JMenuItem(“定点整数原码乘法”);
item4 = new JMenuItem(“浮点加减法”);
menu1.add(item1);
menu2.add(item2);
menu3.add(item3);
menu4.add(item4);
this.setJMenuBar(menubar);}
@Override
public void actionPerformed(ActionEvent e){
String t =mima.getText();
//判断口令是否正确try
if(e.getSource()==queren){
if(t.equals(txt)){
mima.setText(“”);
item1.setEnabled(true);
//口令正确 菜单可用
item2.setEnabled(true);
item3.setEnabled(true);
item4.setEnabled(true);
}
else if(!t.equals(txt)){
JOptionPane.showMeageDialog(rootPane, “密码错误”);
item1.setEnabled(false);
//菜单访问权设置
item2.setEnabled(false);
item3.setEnabled(false);
item4.setEnabled(false);
mima.setText(“”);
cishu++;
if(cishu==3){
JOptionPane.showMeageDialog(rootPane, “密码错误次数太多”);
System.exit(0);
}
}
}
if(e.getSource()==item1){
Ddxs ddxs = new Ddxs();this.dispose();
}else if(e.getSource()==item2){
Bmjj bmjj = new Bmjj();this.dispose();
}else if(e.getSource()==item3){
Ymcf ymcf =new Ymcf();this.dispose();
}else if(e.getSource()==item4){
Fdjj fdjj=new Fdjj();this.dispose();
}
}
}
package xiangmu;/** * * @author pc */import java.lang.Object;import java.awt.*;import java.awt.event.*;
import javax.swing.*;public cla Fdjj extends JFrame implements ActionListener {
JButton JButton1, JButton2, JButton3, JButton4;JLabel name, input, input1, input2, input3, input4, input5, input7, input6;JTextField data, data1, data2, data3, data4, data5, data6, data7;public Fdjj(){
setTitle(“form5”);
Toolkit tool = getToolkit();
tool.getScreenSize();
this.setBounds(400, 100, 600, 400);
this.setLayout(null);
JButton1 = new JButton(“输入”);
JButton1.setFont(new Font(“宋体”,Font.BOLD,15));
JButton1.setBounds(100, 320, 80, 30);
JButton2 = new JButton(“加法”);
JButton2.setFont(new Font(“宋体”,Font.BOLD,15));
JButton2.setBounds(200, 320, 80, 30);
JButton3 = new JButton(“减法”);
JButton3.setFont(new Font(“宋体”,Font.BOLD,15));
JButton3.setBounds(300, 320, 80, 30);
JButton4 = new JButton(“返回”);
JButton4.setFont(new Font(“宋体”,Font.BOLD,15));
JButton4.setBounds(400, 320, 80, 30);
name = new JLabel(“浮点数的加减法运算”, JLabel.CENTER);
name.setFont(new Font(“宋体”,Font.BOLD,25));
name.setBounds(130,-20, 300, 150);
input = new JLabel(“第一个数的阶码:”);
input.setFont(new Font(“宋体”,Font.BOLD,15));
input.setBounds(25, 100, 150, 30);
data = new JTextField(10);
data =new JTextField(“”);data.setBounds(155, 105, 100, 20);
input1 = new JLabel(“尾数:”);
input1.setFont(new Font(“宋体”,Font.BOLD,15));
input1.setBounds(305, 105, 80, 20);
data1 = new JTextField(10);
data1.setBounds(355, 105, 150, 20);
input2 = new JLabel(“第二个数的阶码:”);
input2.setFont(new Font(“宋体”,Font.BOLD,15));
input2.setBounds(25, 150, 150, 30);
data2 = new JTextField(10);
data2.setBounds(155, 155, 100, 20);
input3 = new JLabel(“尾数:”);
input3.setFont(new Font(“宋体”,Font.BOLD,15));
input3.setBounds(305, 155, 80, 20);
data3 = new JTextField(10);data3.setBounds(355, 155, 150, 20);
input4 = new JLabel(“加法的阶码:”);
input4.setFont(new Font(“宋体”,Font.BOLD,15));
input4.setBounds(55, 200, 100, 30);
data4 = new JTextField(10);
data4.setBounds(155, 205, 100, 20);data4.setEnabled(false);
input5 = new JLabel(“尾数:”);
input5.setFont(new Font(“宋体”,Font.BOLD,15));
input5.setBounds(305, 205, 80, 20);
data5 = new JTextField(10);
data5.setBounds(355, 205, 150, 20);data5.setEnabled(false);
input6 = new JLabel(“减法的阶码为:”);
input6.setFont(new Font(“宋体”,Font.BOLD,15));
input6.setBounds(55,250, 100, 30);
data6 = new JTextField(10);data6.setBounds(155, 255, 100, 20);data6.setEnabled(false);
input7 = new JLabel(“尾数:”);
input7.setFont(new Font(“宋体”,Font.BOLD,15));
input7.setBounds(305, 255, 80, 20);
data7 = new JTextField(10);
data7.setBounds(355, 255, 150, 20);data7.setEnabled(false);
JButton1.addActionListener(this);
JButton2.addActionListener(this);
JButton3.addActionListener(this);
JButton4.addActionListener(this);
this.add(name);
this.add(input);this.add(input1);this.add(input2);
this.add(input3);this.add(input4);this.add(input5);
this.add(input6);this.add(input7);
this.add(data);this.add(data2);this.add(data1);this.add(data3);
this.add(data5);this.add(data6);this.add(data7);this.add(data4);
this.add(JButton1);this.add(JButton2);this.add(JButton3);this.add(JButton4);
setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);} String calculate(String s1, String s2){
char ac = '0';
char a1[] = s1.toCharArray(), a2[] = s2.toCharArray();for(int i = a1.length2;i >= 0;i--){
for(int j = i;j >= i;j--){
n[i] = n[i] * 2;
} } for(int i = 0;i
sum = sum + n[i];} sum = sum * signal;return sum;} public String bumaHuanyuan(String s)/* 变形补码还原真值处理,无整数点 */ { if(s.startsWith(“00”)){
s = “+” + s.substring(2);} else if(s.startsWith(“11”)){
String temp = s.substring(2, s.lastIndexOf(“1”));
char c[] = temp.toCharArray();
for(int i = 0;i
if(c[i] == '0')
c[i] = '1';
else
c[i] = '0';
}
temp = new String(c);
s = “-” + temp + s.substring(s.lastIndexOf(“1”));} return s;} public String[] myAdd(String sj1, String sj2, String st1, String st2){ String s[] = new String[2];int n = 0, count = 0, len =(st1.length()1);
}
sj1 = sj2;/* 统一阶码 */ } if(n > 0)/* 第二个数的尾数右移 */ {
for(int i = 1;i
st2 = st2.substring(0, 1)+ st2.substring(0, st2.length()1);
count--;
} } while(count > 0)/* 阶码循环减一 */ {
String temp = sj1.replaceAll(“0”, “1”);
temp = temp.substring(1)+ “1”;
sj1 = calculate(sj1, temp);
count--;} while(count
String temp = sj1.replaceAll(“1”, “0”);
temp = temp.substring(1)+ “1”;
sj1 = calculate(sj1, temp);
count++;} sj1 = bumaHuanyuan(sj1);st1 = st1.substring(0, len + 3);if(st1.endsWith(“1”))/* 尾数舍入处理 */ {
String temp = st1.replaceAll(“1”, “0”);
temp = temp.substring(1)+ “1”;
st1 = calculate(st1, temp);} else if(st1.endsWith(“0”)){ } st1 = st1.substring(0, st1.length()-1);st1 = bumaHuanyuan(st1);/* 尾数补码还原处理 */ s[0] = sj1;s[1] = st1;return s;} public void actionPerformed(ActionEvent e){ if(e.getSource()== JButton1){
data.setText(null);
data1.setText(null);
data2.setText(null);
data3.setText(null);
data4.setText(null);
data5.setText(null);
data6.setText(null);
data7.setText(null);
data.requestFocusInWindow();} if(e.getSource()== JButton2){
String sj1 = jiemaQiubu(data.getText()),sj2 = jiemaQiubu(data2.getText()), st1 = weishuQiubu(data1
.getText()), st2 = weishuQiubu(data3.getText());
if((sj1.length()!= sj2.length())
||(st1.length()!= st2.length())){
JOptionPane.showMeageDialog(this, “请输入长度相等的数据!”, “错误”,JOptionPane.ERROR_MESSAGE);
} else {
String s[] = myAdd(sj1, sj2, st1, st2);
data4.setText(s[0]);
data5.setText(s[1].substring(0, 1)+ “0.” + s[1].substring(1));
}
}
if(e.getSource()== JButton3){
String sj1 = jiemaQiubu(data.getText()),sj2 = jiemaQiubu(data2.getText()), st1 = weishuQiubu(data1
.getText()), st2 = weishuQiubu(data3.getText()), temp;
if((sj1.length()!= sj2.length())
||(st1.length()!= st2.length())){
JOptionPane.showMeageDialog(this, “请输入长度相等的数据!”, “错误”,JOptionPane.ERROR_MESSAGE);
} else {
temp = st2.substring(0, st2.lastIndexOf(“1”));
temp.toCharArray();
for(int i = 0;i
if(c[i] == '0')
c[i] = '1';
else
c[i] = '0';
}
st2 = new String(c)+ st2.substring(st2.lastIndexOf(“1”));
String s[] = myAdd(sj1, sj2, st1, st2);
data6.setText(s[0]);
data7.setText(s[1].substring(0, 1)+ “0.” + s[1].substring(1));
}
} else if(e.getSource()== JButton4){
Window win =new Window();
this.dispose();
} } }
package xiangmu;/** * * @author pc */import java.lang.Object;import java.awt.*;import java.awt.event.*;import javax.swing.*;cla Ddxs extends JFrame implements ActionListener{
JLabel label1,label3,label2;
JTextField f1,f2;
JButton shuru,yma,fanma,buma,yima,fanhui;
public Ddxs(){
this.setBounds(400, 100, 600, 400);
this.setLayout(null);
this.setResizable(false);//窗口大小不许改变
fanhui =new JButton(“返回”);
fanhui.setFont(new Font(“宋体”,Font.BOLD,15));
fanhui.setBounds(500, 320, 80, 30);
fanhui.addActionListener((ActionListener)this);
yma =new JButton(“原码”);
char c[] =
yma.setFont(new Font(“宋体”,Font.BOLD,15));
yma.setBounds(100, 320, 80, 30);
yma.addActionListener((ActionListener)this);
fanma =new JButton(“反码”);
fanma.setFont(new Font(“宋体”,Font.BOLD,15));
fanma.setBounds(200, 320, 80, 30);
fanma.addActionListener((ActionListener)this);//监听
buma =new JButton(“补码”);
buma.setFont(new Font(“宋体”,Font.BOLD,15));
buma.setBounds(300, 320, 80, 30);
buma.addActionListener((ActionListener)this);//监听
yima =new JButton(“移码”);
yima.setFont(new Font(“宋体”,Font.BOLD,15));
yima.setBounds(400, 320, 100, 30);
yima.addActionListener((ActionListener)this);//监听
shuru =new JButton(“输入”);
shuru.setFont(new Font(“宋体”,Font.BOLD,15));
shuru.setBounds(10, 320, 80, 30);
shuru.addActionListener((ActionListener)this);//监听
f1 =new JTextField(“ ”);
//text框
f2=new JTextField(“”);
f1.setBounds(250, 140, 150, 20);
f2.setBounds(250, 200, 150, 20);
f2.setEnabled(false);
label1=new JLabel(“请输入一个二进制数:”);
label1.setBounds(100, 100, 150, 100);
label2=new JLabel(“该数对应的原码:”);
label2.setBounds(122, 197, 100, 30);
label3=new JLabel(“定点整数的机器表示”);
label3.setFont(new Font(“宋体”,Font.BOLD,25));
label3.setBounds(130,-20, 380, 210);
this.add(label1);
this.add(label2);
this.add(label3);
this.add(f1);this.add(f2);
this.add(shuru);this.add(fanma);this.add(yma);this.add(buma);this.add(yima);
this.add(fanhui);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e){
if(e.getSource()==fanhui){
Window win =new Window();
this.dispose();
}
else if(e.getSource()==shuru){
f1.setText(null);
f2.setText(null);
f1.requestFocusInWindow();
}else if(e.getSource()==yma){
label2.setText(“该数对应的原码:”);
//
label2.setBounds(122, 197, 120, 30);
yuanma();
}else if(e.getSource()==fanma){
label2.setText(“该数对应的反码:”);
fanma();
}else if(e.getSource()==buma){
label2.setText(“该数对应的补码:”);
buma();
}else if(e.getSource()==yima){
label2.setText(“该数对应的移码:”);
yima();
}
}
private void yuanma(){
String s1 =f1.getText().trim();
int x =Integer.valueOf(s1, 2);
if(x
StringBuffer s11=new StringBuffer(s1);
s11.setCharAt(0, '1');
f2.setText(s11.toString());
}else if(x>0){
StringBuffer s22=new StringBuffer(s1);
s22.setCharAt(0, '0');
f2.setText(s22.toString());
}
}
private void fanma(){
String s =f1.getText().trim();
int x =Integer.valueOf(s, 2);
int t=s.length()-1;
if(x
StringBuffer s1 = new StringBuffer(s);
s1.deleteCharAt(0);
StringBuffer s2 = new StringBuffer(f1.getText().trim());
s2.deleteCharAt(0);
for(int i=0;i
s2.setCharAt(i, '1');
}
String s21 =s2.toString();
String s11 =s1.toString();
int i1=Integer.valueOf(s11, 2);
int i2 =Integer.valueOf(s21, 2);
String s3 =Integer.toBinaryString(i2^i1);
if(t!=s3.length()){
StringBuffer s4=new StringBuffer(s3);
s4.insert(0, '0');
s3 =s4.toString();
}
f2.setText(“1”+s3);
}else if(x>0){
StringBuffer s1 = new StringBuffer(s);
s1.deleteCharAt(0);
String s11=s1.toString();
f2.setText(“0”+s11);
}
}
private void buma(){
String s =f1.getText().trim();
int x =Integer.valueOf(s, 2);
int t=s.length()-1;
String sub=“1”;
int sub1=Integer.valueOf(sub, 2);
if(x
StringBuffer s1 = new StringBuffer(s);
s1.deleteCharAt(0);
StringBuffer s2 = new StringBuffer(f1.getText().trim());
s2.deleteCharAt(0);
for(int i=0;i
s2.setCharAt(i, '1');
}
String s21 =s2.toString();
String s11 =s1.toString();
int i1=Integer.valueOf(s11, 2);
int i2 =Integer.valueOf(s21, 2);
int sum =i2^i1;
sum+=sub1;
String s3 =Integer.toBinaryString(sum);
if(t!=s3.length()){
StringBuffer s4=new StringBuffer(s3);
s4.insert(0, '0');
s3 =s4.toString();
}
f2.setText(“1”+s3);
}else if(x>0){
StringBuffer s1 = new StringBuffer(s);
s1.deleteCharAt(0);
String s11=s1.toString();
f2.setText(“0”+s11);
}
}
private void yima(){
String s1 =f1.getText().trim();
int x= Integer.valueOf(s1, 2);
if(x
StringBuffer s12 =new StringBuffer(s1);
s12.deleteCharAt(0);
int l=s12.length()-1;
char a=s12.charAt(l);
for(int i=l;i>0;i--){
s12.setCharAt(i, s12.charAt(i-1));
}
s12.setCharAt(0, a);
String shuchu =s12.toString();
f2.setText(“1”+shuchu);
}else if(x>0){
StringBuffer s12 =new StringBuffer(s1);
s12.deleteCharAt(0);
int l=s12.length()-1;
char a=s12.charAt(l);
for(int i=l;i>0;i--){
s12.setCharAt(i, s12.charAt(i-1));
}
s12.setCharAt(0, a);
String shuchu =s12.toString();
f2.setText(“0”+shuchu);
}
}
}
package xiangmu;/** * * @author pc */import java.lang.Object;import java.awt.*;import java.awt.event.*;import javax.swing.*;cla Bmjj extends JFrame implements ActionListener{
JTextField txt1,txt2,txt3,txt4;
JButton b1,b2,b3,b4;
public Bmjj(){
this.setBounds(400, 100, 600, 400);
this.setLayout(null);
this.setResizable(false);//窗口大小不许改变
JLabel label1= new JLabel(“定点整数的变形补码加减运算”);
label1.setFont(new Font(“宋体”,Font.BOLD,26));
label1.setBounds(110, 1, 380, 100);
//Label
JLabel label2 =new JLabel(“请输入第一个数:”);
label2.setFont(new Font(“宋体”,Font.BOLD,15));//改变字体大小
label2.setBounds(130, 100, 150, 30);
JLabel label5 =new JLabel(“请输入第二个数:”);
label5.setFont(new Font(“宋体”,Font.BOLD,15));//改变字体大小
label5.setBounds(130, 150, 150, 30);
JLabel label3 = new JLabel(“加法结果为:”);
label3.setFont(new Font(“宋体”,Font.BOLD,15));//改变字体大小
label3.setBounds(157, 200, 100, 30);
JLabel label4 = new JLabel(“减法结果为:”);
label4.setFont(new Font(“宋体”,Font.BOLD,15));//改变字体大小
label4.setBounds(157,250, 100, 30);
//TextField
txt1 =new JTextField(“”);txt1.setBounds(257,100, 150, 20);
txt2=new JTextField(“”);
txt2.setBounds(257,150, 150, 20);
txt3 =new JTextField(“”);txt3.setBounds(257,200, 150, 20);
txt4 =new JTextField(“”);txt4.setBounds(257,250, 150, 20);
txt3.setEnabled(false);
txt4.setEnabled(false);
b1 = new JButton(“输入”);
//BUtton
b1.setFont(new Font(“宋体”,Font.BOLD,15));
b1.setBounds(100, 320, 80, 30);
b1.addActionListener((ActionListener)this);
b2 = new JButton(“加法”);
b2.setFont(new Font(“宋体”,Font.BOLD,15));
b2.setBounds(200, 320, 80, 30);
b2.addActionListener((ActionListener)this);
b3 = new JButton(“减法”);
b3.setFont(new Font(“宋体”,Font.BOLD,15));
b3.setBounds(300, 320, 80, 30);
b3.addActionListener((ActionListener)this);
b4 = new JButton(“返回”);
b4.setFont(new Font(“宋体”,Font.BOLD,15));
b4.setBounds(400, 320, 80, 30);
b4.addActionListener((ActionListener)this);
this.add(label1);
this.add(label5);this.add(txt1);
this.add(label2);this.add(txt2);
this.add(label3);this.add(txt3);
this.add(label4);this.add(txt4);
this.add(b1);this.add(b2);this.add(b3);this.add(b4);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e){
String s1=txt1.getText().trim();
String s2=txt2.getText().trim();
if(e.getSource()==b1){
b1.requestDefaultFocus();
}else if(e.getSource()==b2){
jiafa(s1,s2);
}else if(e.getSource()==b3){
jianfa(s1,s2);
}else if(e.getSource()== b4){
Window win = new Window();
this.dispose();
}
}
private void jiafa(String s1, String s2){
int x=Integer.valueOf(s1, 2);
int y=Integer.valueOf(s2, 2);
String sum =Integer.toBinaryString(x+y);
txt3.setText(sum);
}
private void jianfa(String s1, String s2){
int x=Integer.valueOf(s1, 2);
int y =Integer.valueOf(s2, 2);
String jian =Integer.toBinaryString(x-y);
txt4.setText(jian);
}
}
package xiangmu;/** * * @author pc */import java.lang.Object;import java.awt.*;import java.awt.event.*;
import javax.swing.*;cla Ymcf extends JFrame implements ActionListener{
TextField t1,t2,t3;
JButton b1,b2,b3;
public Ymcf(){
this.setBounds(400, 100, 600, 400);
this.setLayout(null);
this.setResizable(false);//窗口大小不许改变
//JLabel
JLabel label1 = new JLabel(“请输入被乘数:”);
label1.setFont(new Font(“宋体”,Font.BOLD,15));
label1.setBounds(100, 100, 120, 100);
JLabel label2 =new JLabel(“请输入乘数:”);
label2.setFont(new Font(“宋体”,Font.BOLD,15));
label2.setBounds(115, 150, 100, 100);
JLabel label3 = new JLabel(“乘法结果为:”);
label3.setFont(new Font(“宋体”,Font.BOLD,15));
label3.setBounds(115, 200, 100, 100);
JLabel label4 =new JLabel(“定点整数的原码乘法”);
label4.setFont(new Font(“宋体”,Font.BOLD,25));
label4.setBounds(180,-20, 380, 210);
//TextField
t1=new TextField(“”);t1.setBounds(220, 140, 200, 20);
t2 =new TextField(“”);t2.setBounds(220, 190, 200, 20);
t3 =new TextField(“”);t3.setBounds(220, 240, 200, 20);t3.setEnabled(false);
b1 = new JButton(“输入”);
//BUtton
b1.setFont(new Font(“宋体”,Font.BOLD,15));
b1.setBounds(100, 320, 80, 30);
b1.addActionListener((ActionListener)this);
b2 = new JButton(“乘法”);
b2.setFont(new Font(“宋体”,Font.BOLD,15));
b2.setBounds(250, 320, 80, 30);
b2.addActionListener((ActionListener)this);
b3 = new JButton(“返回”);
b3.setFont(new Font(“宋体”,Font.BOLD,15));
b3.setBounds(400, 320, 80, 30);
b3.addActionListener((ActionListener)this);
this.add(label1);this.add(t1);
this.add(label2);this.add(t2);
this.add(label3);this.add(t3);
this.add(b1);this.add(b2);this.add(b3);
this.add(label4);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e){
if(e.getSource()==b1){
t1.setText(null);
t2.setText(null);
t3.setText(null);
t1.requestFocusInWindow();
}else if(e.getSource()==b2){
String s1 =t1.getText().trim();
String s2 =t2.getText().trim();
chengfa(s1,s2);
}else if(e.getSource()==b3){
Window win=new Window();
this.dispose();
}
}
private void chengfa(String s1, String s2){
StringBuffer fuhao1=new StringBuffer(s1);
StringBuffer fuhao2 =new StringBuffer(s2);
int x=Integer.valueOf(s1, 2);
int y =Integer.valueOf(s2, 2);
if((x
StringBuffer s11 = new StringBuffer(s1);
StringBuffer s21 =new StringBuffer(s2);
s11.deleteCharAt(0);
s21.deleteCharAt(0);
s1 =s11.toString();
s2=s21.toString();
int x1 =Integer.valueOf(s1, 2);
int x2 =Integer.valueOf(s2, 2);
int sub =x1*x2;
String sub1 =Integer.toBinaryString(sub);
t3.setText(sub1);
}else if((x0)/*||(fuhao1.charAt(0)=='1'&&fuhao2.charAt(0)=='0')*/){
StringBuffer s11 = new StringBuffer(s1);
StringBuffer s21 =new StringBuffer(s2);
s11.deleteCharAt(0);
s21.deleteCharAt(0);
s1 =s11.toString();
s2=s21.toString();
int x1 =Integer.valueOf(s1, 2);
int x2 =Integer.valueOf(s2, 2);
int sub =x1*x2;
String sub1 =Integer.toBinaryString(sub);
t3.setText(sub1);
}else if((x>0&&y
StringBuffer s11 = new StringBuffer(s1);
StringBuffer s21 =new StringBuffer(s2);
s11.deleteCharAt(0);
s21.deleteCharAt(0);
s1 =s11.toString();
s2=s21.toString();
int x1 =Integer.valueOf(s1, 2);
int x2 =Integer.valueOf(s2, 2);
int sub =x1*x2;
String sub1 =Integer.toBinaryString(sub);
t3.setText(sub1);
}else if((x>0&&y>0)/*||(fuhao1.charAt(0)=='0'&&fuhao2.charAt(0)=='0')*/){
StringBuffer s11 = new StringBuffer(s1);
StringBuffer s21 =new StringBuffer(s2);
s11.deleteCharAt(0);
s21.deleteCharAt(0);
s1 =s11.toString();
s2=s21.toString();
int x1 =Integer.valueOf(s1, 2);
int x2 =Integer.valueOf(s2, 2);
int sub =x1*x2;
String sub1 =Integer.toBinaryString(sub);
t3.setText(sub1);
}
}
}