//package 娱乐;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.text.DecimalFormat;
import javax.swing.*;
public class 计算器 extends JFrame implements ActionListener, ItemListener {
private JButton an[];
private JButton qingkong, zh;
private JTextField k;
private JPanel rq1, rq2, rq3;
int zz = 1;
private String string[] = { "7", "8", "9", "/", "6", "5", "4", "*", "3",
"2", "1", "-", "0", ".", "=", "+" };
private String s = "", shu1 = "", shu2 = "", shu3 = "";
private static int fo = 0;
JComboBox a;
private boolean ff = true;
public 计算_复杂() {
super("进制计算器");
Container c = getContentPane();
c.setLayout(new FlowLayout());
rq1 = new JPanel();
k = new JTextField(13);
rq1.add(k);
qingkong = new JButton("C");
rq1.add(qingkong);
c.add(rq1);
rq3 = new JPanel();
a = new JComboBox();
a.addItem("10进制转换为2进制");
a.addItem("10进制转换为8进制");
a.addItem("10进制转换为16进制");
a.addItem("2进制转换为8进制");
a.addItem("2进制转换为10进制");
a.addItem("2进制转换为16进制");
a.addItem("8进制转换为2进制");
a.addItem("8进制转换为10进制");
a.addItem("8进制转换为16进制");
a.addItem("16进制转换为2进制");
a.addItem("16进制转换为8进制");
a.addItem("16进制转换为10进制");
rq3.add(a);
zh = new JButton("转");
rq3.add(zh);
c.add(rq3);
rq2 = new JPanel();
rq2.setLayout(new GridLayout(4, 4, 10, 10));
an = new JButton[string.length];
for (int i = 0; i < string.length; i++) {
an[i] = new JButton(string[i]);
an[i].addActionListener(this);
rq2.add(an[i]);
}
c.add(rq2);
qingkong.addActionListener(this);
zh.addActionListener(this);
a.addItemListener(this);
setSize(200, 250);
setVisible(true);
try {
JMen