资源简介
Java课程设计中的科学型和复合型计算器的源代码,请多多指教!!
代码片段和文件信息
package calculator;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.styleConstants;
import java.awt.*;
import java.awt.event.*;
public class Calculator extends Jframe implements ActionListener
{
Jframe frame;
JMenuItem copypastesciencebasichelpaboutbaidupaintingnoted;
JRadioButton sixteenteneighttwo;
JPanel cp1;
JPanel cp2;
JPanel cp3;
JButton backspacececnum0num1num2num3num4num5num6num7num8num9;
Container container;
ButtonGroup btg;
JTextField textfield1;
String copycontent=““;
JButton plus;
JButton minus;
JButton multify;
JButton divide;
JButton power;
JButton qiuyi;
JButton equal;
JButton negative;
JButton point;
JButton sqrt;
JButton last;
JButton a;
JButton b;
JButton cc;
JButton d;
JButton ee;
JButton f;
JButton sin;
JButton cos;
JButton tan;
JMenuBar mainMenu;
JMenu editMenu ;
JMenu viewMenu ;
JMenu helpMenu ;
//JTextField textfield2=new JTextField();
objConversion convert = new objConversion();
boolean clickable=trueclear=true;
int all=0;
double histroy; //存放之前的数据
String sign;//存放符号
int system=10first=1;//system 进制first 第一次存放的数字,便于判断
public void basicSettings(){
this.settitle(“计算器“);
this.setSize(330250);
this.setLocation(250200);
this.setResizable(false);
this.setIconImage(new ImageIcon(“./src/calculator/calculator.jpg“).getImage()); //设置图标
}
public void jpanelnamings(){
cp1=new JPanel();
cp1.setLayout(new GridLayout(16));
cp2=new JPanel();
cp3=new JPanel();
cp3.setLayout(new GridLayout(4555));
}
public void textfield1Settings(){
textfield1=new JTextField(100);
textfield1.setText(“0.“);
textfield1.setHorizontalAlignment(JTextField.RIGHT);//从右到左
textfield1.setEditable(false);
//textfield1.setBackground(new Color(255 255 255));
}
public void containerSettings(){
container=getContentPane();
container.add(cp1“North“);
container.add(cp2“Center“);
container.add(cp3“South“);
}
public void systemSettings(){//进制设定
sixteen=new JRadioButton(“十六进制“);
sixteen.setVisible(false);
ten=new JRadioButton(“十进制“true);
ten.setVisible(false);
eight=new JRadioButton(“八进制“);
eight.setVisible(false);
two=new JRadioButton(“二进制“);
two.setVisible(false);
sixteen.addActionListener(this);
ten.addActionListener(this);
eight.addActionListener(this);
two.addActionListener(this);
}
public void buttonGroupSettings(){//多斥作用域设定
btg=new ButtonGroup();
btg.add(sixteen);
btg.add(ten);
btg.add(eight);
btg.add(two);
cp1.add(textfield1);
cp2.add(sixteen);
cp2.add(ten);
cp2.add(eight);
cp2.add(two);
}
public void otherButtonSettings(){
backspace=new JButton(“退格“);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-12-29 14:03 计算器\
文件 301 2013-12-29 14:03 计算器\.classpath
文件 385 2013-12-29 14:03 计算器\.project
目录 0 2013-12-29 14:03 计算器\.settings\
文件 629 2013-12-29 14:03 计算器\.settings\org.eclipse.jdt.core.prefs
目录 0 2014-05-05 23:52 计算器\bin\
目录 0 2014-05-05 23:52 计算器\bin\calculator\
文件 2466 2014-05-05 23:52 计算器\bin\calculator\Calculator$objConversion.class
文件 690 2014-05-05 23:52 计算器\bin\calculator\Calculator$WindowDestroyer.class
文件 16521 2014-05-05 23:52 计算器\bin\calculator\Calculator.class
文件 19164 2013-12-29 14:29 计算器\bin\calculator\calculator.jpg
文件 2827 2014-05-05 23:52 计算器\bin\calculator\Specification.class
目录 0 2013-12-29 14:03 计算器\src\
目录 0 2013-12-29 14:29 计算器\src\calculator\
文件 23683 2013-12-30 12:03 计算器\src\calculator\Calculator.java
文件 19164 2013-12-29 14:29 计算器\src\calculator\calculator.jpg
评论
共有 条评论