求一份 完整的科学计算器的程序,用netbeans (java)开发的 。有的,发到我的邮箱1491549690@qq.com 谢谢

 我来答
梓一888
2012-05-12 · 超过31用户采纳过TA的回答
知道答主
回答量:101
采纳率:0%
帮助的人:30万
展开全部
import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Button;
import java.awt.TextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;

public class ddd extends JFrame {

private JPanel contentPane;
private String a1="";
private int data1;
private String a2="";
private int data2;
private int opt;
TextField textField = new TextField();
Button button = new Button("0");
Button button_1 = new Button("1");
Button button_2 = new Button("2");
Button button_3 = new Button("3");
Button button_4 = new Button("4");
Button button_5 = new Button("5");
Button button_6 = new Button("6");
Button button_7 = new Button("7");
Button button_8 = new Button("8");
Button button_9 = new Button("9");
Button button_11 = new Button("-");
Button button_12 = new Button("*");
Button button_13 = new Button("/");
Button button_14 = new Button("=");
private final Button button_15 = new Button("+");

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ddd frame = new ddd();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public ddd() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);

button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});
button.setBounds(64, 74, 42, 23);
contentPane.add(button);

button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});
button_1.setBounds(122, 74, 42, 23);
contentPane.add(button_1);
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});

button_2.setBounds(182, 74, 42, 23);
contentPane.add(button_2);
button_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});

button_3.setBounds(64, 103, 42, 23);
contentPane.add(button_3);
button_4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});

button_4.setBounds(122, 103, 42, 23);
contentPane.add(button_4);
button_5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});

button_5.setBounds(182, 103, 42, 23);
contentPane.add(button_5);
button_6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});

button_6.setBounds(64, 132, 42, 23);
contentPane.add(button_6);
button_7.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});

button_7.setBounds(122, 132, 42, 23);
contentPane.add(button_7);
button_8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});

button_8.setBounds(182, 132, 42, 23);
contentPane.add(button_8);

button_11.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(a1.intern()!="")
data1=Integer.parseInt(a1);
a1="";
opt=2;
}
});
button_11.setBounds(241, 103, 42, 23);
contentPane.add(button_11);
button_12.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(a1.intern()!="")
data1=Integer.parseInt(a1);
a1="";
opt=3;
}
});

button_12.setBounds(241, 132, 42, 23);
contentPane.add(button_12);
button_13.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(a1.intern()!="")
data1=Integer.parseInt(a1);
a1="";
opt=4;
}
});

button_13.setBounds(241, 161, 42, 23);
contentPane.add(button_13);
button_14.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int result=0;
data2=Integer.parseInt(a1);
if(opt==2)
result=data1-data2;
if(opt==3)
result=data1*data2;
if(opt==4)
result=data1/data2;
if(opt==5)
result=data1+data2;

textField.setText(Integer.toString(result));
data1=result;
a1="";
a2="";
data2=0;
}
});

button_14.setBounds(182, 161, 42, 23);
contentPane.add(button_14);

textField.setBounds(64, 35, 219, 23);
contentPane.add(textField);

Button button_10 = new Button("9");
button_10.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
a1=a1+e.getActionCommand();
textField.setText(a1);
}
});
button_10.setBounds(64, 161, 42, 23);
contentPane.add(button_10);
button_15.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(a1.intern()!="")
data1=Integer.parseInt(a1);
a1="";
opt=5;
}
});
button_15.setBounds(241, 74, 42, 23);

contentPane.add(button_15);

//contentPane.add(button_16);

//contentPane.add(button_17);
setVisible(true);
}
}这是程序 可视化界面自己弄
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式