百韵网 >>  正文

急求JAVA计算器源代码 急求java科学计算器源代码

来源:www.baiyundou.net   日期:较早时间
//HTML
<html>
<applet code=SZJSQ.class width=400 height=180>
</applet>
</html>
//APPLET
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
public class SZJSQ extends JApplet implements ActionListener
{
boolean i=true;
private JButton num0=new JButton("0");
private JButton num1=new JButton("1");
private JButton num2=new JButton("2");
private JButton num3=new JButton("3");
private JButton num4=new JButton("4");
private JButton num5=new JButton("5");
private JButton num6=new JButton("6");
private JButton num7=new JButton("7");
private JButton num8=new JButton("8");
private JButton num9=new JButton("9");
private JButton zuok=new JButton("(");
private JButton youk=new JButton(")");
private JButton dian=new JButton(".");
private JButton NULL=new JButton("N");
private JButton plu=new JButton("+");
private JButton min=new JButton("-");
private JButton mul=new JButton("x");
private JButton div=new JButton("/");
private JButton equ=new JButton("=");
private JButton cle=new JButton("C");//清除
private JTextField space=new JTextField(30);

public void init()
{
JPanel text=new JPanel();
text.setLayout(new FlowLayout());
text.add(space);
JPanel buttons=new JPanel();
buttons.setLayout(new GridLayout(5,4));
buttons.add(num9);
buttons.add(num8);
buttons.add(num7);
buttons.add(plu);
buttons.add(num6);
buttons.add(num5);
buttons.add(num4);
buttons.add(min);
buttons.add(num3);
buttons.add(num2);
buttons.add(num1);
buttons.add(mul);
buttons.add(num0);
buttons.add(cle);
buttons.add(equ);
buttons.add(div);
buttons.add(zuok);
buttons.add(youk);
buttons.add(dian);
buttons.add(NULL);
(num9).addActionListener(this);
(num8).addActionListener(this);
(num7).addActionListener(this);
(num6).addActionListener(this);
(num5).addActionListener(this);
(num4).addActionListener(this);
(num3).addActionListener(this);
(num2).addActionListener(this);
(num1).addActionListener(this);
(num0).addActionListener(this);
(plu).addActionListener(this);
(min).addActionListener(this);
(mul).addActionListener(this);
(div).addActionListener(this);
(equ).addActionListener(this);
(cle).addActionListener(this);
(zuok).addActionListener(this);
(youk).addActionListener(this);
(dian).addActionListener(this);
setLayout(new BorderLayout());
add("North",text);
add("South",buttons);
space.setText("0");
}

public void actionPerformed(ActionEvent e)
{

if(e.getSource()==num9)
{
if(i==true)
{
space.setText("9");
i=false;
}
else space.setText(space.getText()+'9');
}
if(e.getSource()==num8)
{
if(i==true)
{
space.setText("8");
i=false;
}
else space.setText(space.getText()+'8');
}
if(e.getSource()==num7)
{
if(i==true)
{
space.setText("7");
i=false;
}
else space.setText(space.getText()+'7');
}
if(e.getSource()==num6)
{
if(i==true)
{
space.setText("6");
i=false;
}
else space.setText(space.getText()+'6');
}
if(e.getSource()==num5)
{
if(i==true)
{
space.setText("5");
i=false;
}
else space.setText(space.getText()+'5');
}
if(e.getSource()==num4)
{
if(i==true)
{
space.setText("4");
i=false;
}
else space.setText(space.getText()+'4');
}
if(e.getSource()==num3)
{
if(i==true)
{
space.setText("3");
i=false;
}
else space.setText(space.getText()+'3');
}
if(e.getSource()==num2)
{
if(i==true)
{
space.setText("2");
i=false;
}
else space.setText(space.getText()+'2');
}
if(e.getSource()==num1)
{
if(i==true)
{
space.setText("1");
i=false;
}
else space.setText(space.getText()+'1');
}
if(e.getSource()==num0)
{
if(i==true)
{
space.setText("0");
i=false;
}
else space.setText(space.getText()+'0');
}
if(e.getSource()==zuok)
{
if(i==true)
{
space.setText("(");
i=false;
}
else space.setText(space.getText()+'(');
} if(e.getSource()==youk)
{
if(i==false)
space.setText(space.getText()+')');
}
if(e.getSource()==dian)
{
if(i==false)
space.setText(space.getText()+'.');
}
if(e.getSource()==plu)
{
space.setText(space.getText()+'+');
i=false;
}
if(e.getSource()==min)
{
space.setText(space.getText()+'-');
i=false;
}
if(e.getSource()==mul)
{
space.setText(space.getText()+'*');
i=false;
}
if(e.getSource()==div)
{
space.setText(space.getText()+'/');
i=false;
}
if(e.getSource()==equ)
{
space.setText(String.valueOf(Calculator(space.getText())));
i=true;
}
if(e.getSource()==cle)
{
space.setText("0");
i=true;
}

}

public double Calculator(String f)//科学计算
{
int i=0,j=0,k;
char c;
StringBuffer s=new StringBuffer();
s.append(f);
s.append('=');
String formula=s.toString();
char[] anArray;
anArray=new char[50];
Stack<Character> mystack=new Stack<Character>();
while(formula.charAt(i)!='=')
{
c=formula.charAt(i);
switch(c)
{
case '(': mystack.push(new Character(c));
i++;
break;
case ')':
while(mystack.peek().charValue()!='(')
{
anArray[j++]=mystack.pop().charValue();
}
mystack.pop();
i++;
break;
case '+':
case '-':
while(!mystack.empty()&&mystack.peek().charValue()!='(')
{
anArray[j++]=mystack.pop().charValue();

}
mystack.push(new Character(c));
i++;
break;
case '*':
case '/':
while(!mystack.empty()&&(mystack.peek().charValue()=='*'||mystack.peek().charValue()=='/'))
{
anArray[j++]=mystack.pop().charValue();
}
mystack.push(new Character(c));
i++;
break;
case' ': i++;
break;
default: while((c>='0'&&c<='9')||c=='.')
{
anArray[j++]=c;
i++;
c=formula.charAt(i);
}
anArray[j++]='#';
break;
}
}
while(!(mystack.empty()))
anArray[j++]=mystack.pop().charValue();

i=0;
int count;
double a,b,d;
Stack<Double> mystack1 =new Stack<Double>();
while(i<j)
{
c=anArray[i];
switch(c)
{
case '+':
a=mystack1.pop().doubleValue();
b=mystack1.pop().doubleValue();
d=b+a;
mystack1.push(new Double(d));
i++;
break;
case '-':
a=mystack1.pop().doubleValue();
b=mystack1.pop().doubleValue();
d=b-a;
mystack1.push(new Double(d));
i++;
break;
case '*':
a=mystack1.pop().doubleValue();
b=mystack1.pop().doubleValue();
d=b*a;
mystack1.push(new Double(d));
i++;
break;
case '/':
a=mystack1.pop().doubleValue();
b=mystack1.pop().doubleValue();
if(a!=0)
{
d=b/a;
mystack1.push(new Double(d));
i++;
}
else
{
System.out.println("Error!");
}
break;
default:
d=0;count=0;
while((c>='0'&&c<='9'))
{
d=10*d+c-'0';
i++;
c=anArray[i];
}
if(c=='.')
{
i++;
c=anArray[i];
while((c>='0'&&c<='9'))
{
count++;
d=d+(c-'0')/Math.pow(10,count);
i++;
c=anArray[i];
}
}
if(c=='#')
mystack1.push(new Double(d));
i++;
break;
}
}
return(mystack1.peek().doubleValue());
}
}

目前只能做10以内的任何四则运算,如请输入四则运算表达式:8/2+6/3+(((6+4)*2)+0)/2
其结果为:16.0
目前这段代码有一个问题:无法进行10以上的计算,如计算:8/2+6/3+(((6+4)*2)+10)/2,则得不到正确的结果。

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;

public class GetResult
{
public GetResult()
{

}
//判断是否为操作符,
//在ASCII码中,( is 40;)is 41;+ is 43;- is 45;* is 42;/ is 47
public boolean isOperator(int operator)
{
if(operator==40 || operator==41 || operator==43
|| operator==45 ||operator==42 || operator==47)
return true;
else
return false;
}

public int getPriority(int operator)
{
if(operator==43 || operator==45 || operator==40)
return 1;
else if(operator==42 || operator==47 || operator==41)
return 2;
else
return 0;
}

public static void main(String[] args)
{
//中序表达式
String inOrder="";
//操作符堆栈,保存输入的四则表达式中的所有运算符
Stack<Character> operators=new Stack<Character>();
//存放用于计算结果的操作数
Stack<Float> numberStack=new Stack<Float>();
//用来遍历输入的中序表达式
int position=0;
//计算时,用来保存计算结果
float result=0;
//后序表达式
String postOrder="";
//遍历后序表达式,存放后序表达式中的每个元素
List<Character> list=new ArrayList<Character>();
int forward=0;

System.out.print("请输入四则运算表达式:");
BufferedReader bur=new BufferedReader(new InputStreamReader(System.in));
try
{
inOrder=bur.readLine();
} catch (IOException e)
{
e.printStackTrace();
}
GetResult expression=new GetResult();
while(true)
{
//判断是否为操作符
if(expression.isOperator(inOrder.charAt(position)))
{
//第一种情况:判断操作符是否是(,如果是的话,就直接压入堆栈中;
//第二种情况:如果堆栈为空,也将操作符直接压入堆栈中。
if((char)inOrder.charAt(position)=='(' || operators.isEmpty())
{
operators.push(inOrder.charAt(position));
}
else
{
//如果操作符是),则输出堆栈中所有的操作符,直到取出(
if((char)inOrder.charAt(position)==')')
{
while(!operators.isEmpty() && operators.peek()!=40)
postOrder+=operators.pop().toString();
operators.pop();
}
else
{
//比较操作符优先级,如果新的操作符优先级小于堆栈顶端操作符的优先级的话,则输出堆栈中所有的操作符
if(!operators.isEmpty() && expression.getPriority((int)inOrder.charAt(position))<
expression.getPriority(operators.peek()))
{
while(!operators.isEmpty() && operators.peek()!=40)
postOrder+=operators.pop().toString();
}
operators.push(inOrder.charAt(position));
}
}
}
else
postOrder+=inOrder.charAt(position);
position++;
if(position>inOrder.length()-1)
break;
}
//如果操作符堆栈中还有操作符,则直接输出。
while(!operators.isEmpty())
postOrder+=operators.pop().toString();
System.out.println("后续表达式为:"+postOrder);
//将后序表达式转化为list表
for(int i=0;i<postOrder.length();i++)
{
char word=postOrder.charAt(i);
list.add(word);
}
//遍历后序表达式的list表
Iterator<Character> iter=list.iterator();
while(iter.hasNext())
{
char oper=iter.next();
//如果不是操作符,则直接压入堆栈中,用于后面的计算
if(!expression.isOperator(oper))
{
numberStack.push((float)oper-48);
}
//如果是操作符,则从操作数堆栈中取出两个操作数进行计算,
//计算后,再将结果压入堆栈中。
else
{
float number1=numberStack.pop();
float number2=numberStack.pop();
switch(oper)
{
case 43:
result=number2+number1;
numberStack.push(result);
break;
case 45:
result=number2-number1;
numberStack.push(result);
break;
case 42:
result=number2*number1;
numberStack.push(result);
break;
case 47:
if(number2%number1==0)
{

}
result=number2/number1;
numberStack.push(result);
break;
}
forward++;
if(forward>postOrder.length()-2)
break;
}
}
System.out.println(result);
}
}

//去年做的,没有四则混合运算功能,不过加上这个功能应该不难,我现在忙,没那个精力,不好意思
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class Calculator extends JFrame implements ActionListener,KeyListener{
String s="";//S 控制文本框
float k=0;//K P 保存值
float p=0;
int b=0;//控制运算符号
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JTextField text=new JTextField(10);
GridLayout gridLayout=new GridLayout();
JButton bc=new JButton("复位");
JButton b0=new JButton("0");
JButton b1=new JButton("1");
JButton b2=new JButton("2");
JButton b3=new JButton("3");
JButton b4=new JButton("4");
JButton b5=new JButton("5");
JButton b6=new JButton("6");
JButton b7=new JButton("7");
JButton b8=new JButton("8");
JButton b9=new JButton("9");
JButton bd=new JButton(".");
JButton bj=new JButton("+");
JButton bji=new JButton("-");
JButton bs=new JButton("*");
JButton bchu=new JButton("/");
JButton bden=new JButton("=");
private void init(){
gridLayout.setColumns(4);
gridLayout.setRows(4);
gridLayout.setHgap(8);
gridLayout.setVgap(8);
text.setHorizontalAlignment(JTextField.RIGHT );
p1.add(text,"West");
p1.add(bc,"East");
p2.setLayout(gridLayout);
p2.add(b7);
p2.add(b8);
p2.add(b9);
p2.add(bchu);
p2.add(b4);
p2.add(b5);
p2.add(b6);
p2.add(bs);
p2.add(b1);
p2.add(b2);
p2.add(b3);
p2.add(bji);
p2.add(b0);
p2.add(bd);
p2.add(bj);
p2.add(bden);

}
private void listener(){
bc.addActionListener(this);
b0.addActionListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
bd.addActionListener(this);
bj.addActionListener(this);
bji.addActionListener(this);
bs.addActionListener(this);
bchu.addActionListener(this);
bden.addActionListener(this);
}
public Calculator() {
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
this.init();
this.listener();
this.add(p1,"North");
this.add(p2,"Center");

}
public static void main(String[] args) {
Calculator mainframe=new Calculator();
mainframe.setSize(200,250);
mainframe.setLocationRelativeTo(null);//居中
mainframe.setTitle("calculator");
mainframe.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand()=="0"){
if(b!=5){
s=s+"0";
text.setText(s);
}

}
if(e.getActionCommand()=="1"){
if(b!=5){
s=s+"1";
text.setText(s);
}
}
if(e.getActionCommand()=="2"){
if(b!=5){
s=s+"2";
text.setText(s);
}
}
if(e.getActionCommand()=="3"){
if(b!=5){
s=s+"3";
text.setText(s);
}
}
if(e.getActionCommand()=="4"){
if(b!=5){
s=s+"4";
text.setText(s);
}
}
if(e.getActionCommand()=="5"){
if(b!=5){
s=s+"5";
text.setText(s);
}
}
if(e.getActionCommand()=="6"){
if(b!=5){
s=s+"6";
text.setText(s);
}
}
if(e.getActionCommand()=="7"){
if(b!=5){
s=s+"7";
text.setText(s);
}
}
if(e.getActionCommand()=="8"){
if(b!=5){
s=s+"8";
text.setText(s);
}
}
if(e.getActionCommand()=="9"){
if(b!=5){
s=s+"9";
text.setText(s);
}
}
if(e.getActionCommand()=="."){
if(b!=5){
if(s.indexOf(".")==-1)
s=s+".";
text.setText(s);
}
}
if(e.getActionCommand()=="复位"){
s="";
text.setText(s);
k=0;
p=0;
b=0;
}
if(e.getActionCommand()=="+"){
if(s!=""){
//k=Float.parseFloat(s);
if(b!=0&&b!=5)
s=this.equal(s, p, k, b);
k=Float.parseFloat(s);
text.setText(s);

s="";
}
b=1;
}
if(e.getActionCommand()=="-"){
if(s!=""){
if(b!=0&&b!=5)
s=this.equal(s, p, k, b);
k=Float.parseFloat(s);
text.setText(s);

s="";
}
b=2;
}
if(e.getActionCommand()=="*"){
if(s!=""){
if(b!=0&&b!=5)
s=this.equal(s, p, k, b);
k=Float.parseFloat(s);
text.setText(s);

s="";
}

b=3;
}
if(e.getActionCommand()=="/"){
if(s!=""){
if(b!=0&&b!=5)
s=this.equal(s, p, k, b);
k=Float.parseFloat(s);
text.setText(s);
s="";
}
b=4;
}
if(e.getActionCommand()=="="){
s=equal(s, p, k, b);
text.setText(s);
b=5;//b=5控制等号以后不能直接跟数字
}

}
public String equal(String s,float p,float k,int b){
if(s!=""){
//System.out.println("program is run here");
p=Float.parseFloat(s);
if(b==1)
s=""+(p+k);
if(b==2)
s=""+(k-p);
if(b==3)
s=""+(p*k);
if(b==4)
if(p==0){
s="除数不能为零";
}else
s=""+(k/p);
}

return s;
}
public void keyPressed(KeyEvent e) {
//if(e.getKeyLocation()=="+")

}
public void keyReleased(KeyEvent arg0) {

}
public void keyTyped(KeyEvent arg0) {

}

}

急求java科学计算器源代码~

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class Counter extends WindowAdapter
{
static JFrame f=new JFrame("计算器");
static JTextField text1=new JTextField("0.");
static String source="";
static String cal="";
static String object="";
static boolean flag=false;
static boolean flag1=true;
static boolean flag2=false;
public void init()
{
try
{
Container c=f.getContentPane();
JPanel pan1=new JPanel();
JButton b1=new JButton("1");
JButton b2=new JButton("2");
JButton b3=new JButton("3");
JButton b4=new JButton("4");
JButton b5=new JButton("5");
JButton b6=new JButton("6");
JButton b7=new JButton("7");
JButton b8=new JButton("8");
JButton b9=new JButton("9");
JButton b0=new JButton("0");
JButton b11=new JButton("+");
JButton b12=new JButton("-");
JButton b13=new JButton("*");
JButton b14=new JButton("/");
JButton b15=new JButton(".");
JButton b16=new JButton("=");
JButton bclar=new JButton("清零");
text1.setHorizontalAlignment(JTextField.RIGHT);
c.add(text1,"North");
c.add(pan1);
A aa=new A();
Result re=new Result();
Opertion op=new Opertion();
Clar cl=new Clar();
b1.addActionListener(aa);
b2.addActionListener(aa);
b3.addActionListener(aa);
b4.addActionListener(aa);
b5.addActionListener(aa);
b6.addActionListener(aa);
b7.addActionListener(aa);
b8.addActionListener(aa);
b9.addActionListener(aa);
b0.addActionListener(aa);
b11.addActionListener(op);
b12.addActionListener(op);
b13.addActionListener(op);
b14.addActionListener(op);
b16.addActionListener(re);
b15.addActionListener(aa);
bclar.addActionListener(cl);
pan1.add(b1);
pan1.add(b2);
pan1.add(b3);
pan1.add(b11);
pan1.add(b4);
pan1.add(b5);
pan1.add(b6);
pan1.add(b12);
pan1.add(b7);
pan1.add(b8);
pan1.add(b9);
pan1.add(b13);
pan1.add(b0);
pan1.add(b15);
pan1.add(b16);
pan1.add(b14);
pan1.add(bclar);
f.setSize(200,220);
f.setVisible(true);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}

}
class A implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String a=text1.getText();
String s=e.getActionCommand();
if(a.equals("0.")||a.equals("+")||a.equals("-")||a.equals("*")||a.equals("/"))
text1.setText(s);
else {
if(flag2)
{
text1.setText(s);
flag2=false;
}
else
text1.setText(a+s);

}
}
}
class Opertion implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
cal=e.getActionCommand();
if(flag1==true)
source=text1.getText();
text1.setText(cal);
flag1=false;
flag=true;
}
}
class Result implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
double num1;
num1=Double.parseDouble(source);
object=text1.getText();
double num2;
num2=Double.parseDouble(object);
double result=0;
if(cal.equals("+"))
result=num1+num2;
if(cal.equals("-"))
result=num1-num2;
if(cal.equals("*"))
result=num1*num2;
if(cal.equals("/"))
if(num2==0)
text1.setText("除数不能为0");
else
result=num1/num2;
String s1=Double.toString(result);
text1.setText(s1);
flag1=true;
flag2=true;
}
}
class Clar implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
text1.setText("0.");
}
}

public static void main(String[] args)
{
Counter count=new Counter();
count.init();
}

public void windowClosing(WindowEvent e){
System.exit(1);
}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
}

代码是:码
跪求高人给代码!!!
我有更好回答

匿名用户
推荐于 2016-11-11
Private Sub Command1_Click()
Select Case Text2.Text
Case "+"
Text4.Text = Str(Val(Text1.Text) + Val(Text3.Text))
Case "-"
Text4.Text = Str(Val(Text1.Text) - Val(Text3.Text))
Case "*"
Text4.Text = Str(Val(Text1.Text) * Val(Text3.Text))
Visual Basic(简称VB)是Microsoft公司开发的一种通用的基于对象的程序设计语言,为结构化的、模块化的、面向对象的、包含协助开发环境的事件驱动为机制的可视化程序设计语言。是一种可用于微软自家产品开发的语言。
“Visual” 指的是开发图形用户界面 (GUI) 的方法——不需编写大量代码去描述界面元素的外观和位置,而只要把预先建立的对象add到屏幕上的一点即可。
“Basic”指的是 BASIC (Beginners All-Purpose Symbolic Instruction Code) 语言,是一种在计算技术发展历史上应用得最为广泛的语言。
Visual Basic源自于BASIC编程语言。VB拥有图形用户界面(GUI)和快速应用程序开发(RAD)系统,可以轻易的使用DAO、RDO、ADO连接数据库,或者轻松的创建Active X控件,用于高效生成类型安全和面向对象的应用程序。
程序员可以轻松的使用VB提供的组件快速建立一个应用程序。

相关要点总结:

18141647159:简单计算器的源代码
冶克答:2013-11-12 c语言图形界面简单计算器源代码,急求 11 2013-12-28 用c语言程序设计一个简单计算器,求其源代码 45 2010-05-17 求Java编的简单计算器源代码 8 2017-03-31 js简单计算器源代码 2015-03-18 用易语言做一个简单的计算器,如下图,求源码 8 2010-06-24 用c语言程序设计一个简单计算器...

18141647159:java计算器源代码
冶克答:import java.awt.event.ActionEvent;import java.awt.event.ActionListener public class NewJFrame extends javax.swing.JFrame { public NewJFrame() { initComponents();} private void initComponents() { jPanel1 = new javax.swing.JPanel();jLabel1 = new javax.swing.JLabel();jLabel2 = ...

18141647159:java 写的计算器源代码只实现加减乘除四则运算即可
冶克答:JFrame frame=new JFrame("sunshine---计算器");JTextField jg_TextField=new JTextField(jg,20);//20列 JButton clear_Button=new JButton("清除");JButton button0=new JButton("0");JButton button1=new JButton("1");JButton button2=new JButton("2");JButton button3=new JButton...

18141647159:求一个JAVA计算器源代码。不要按钮的那种。速度。。急用
冶克答://实例化所有按钮、设置其前景色并注册监听器 b0=new Button("Backspace");b0.setForeground(Color.red);b0.addActionListener(new Bt());b1=new Button("CE");b1.setForeground(Color.red);b1.addActionListener(new Bt());b2=new Button("C");b2.setForeground(Color.red);b2.addAction...

18141647159:急求一份java计算器源代码 带有保存功能 能运算加减乘除等算法_百度知 ...
冶克答:Frame fm = new Frame("简易计算器");for (int i = 0; i <= 16; i++) { b[i] = new Button(ss[i]);} for (int i = 0; i <= 15; i++) { p2.add(b[i]);} b[16].setBackground(Color.blue);txt = new TextField(15);txt.setEditable(false);for (int i = 0...

18141647159:用java写的电脑附件中计算器的源代码
冶克答:用java写的电脑附件中计算器的源代码 哪位大侠有界面要像电脑中的计算器一样不过只要实现标准型界面中的功能... 哪位大侠有界面要像电脑中的计算器一样 不过只要实现标准型界面中的功能 展开  我来答 1个回答 #热议# 蓝洁瑛生前发生了什么? thinkpack 2009-08-30 · TA获得超过2829个赞 知道大有...

18141647159:求一个java计算器原代码,最好有文档说明。
冶克答:f=new Frame("计算器");p=new Panel();p.setLayout(new GridLayout(4,4));tf=new TextField(30);b1=new Button("7");b2=new Button("8");b3=new Button("9");b4=new Button("+");b5=new Button("4");b6=new Button("5");b7=new Button("6");b8=new Button("-");b9=...

18141647159:计算器源代码
冶克答:import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JTextField;/** * 一个计算器,与Windows附件自带计算器的标准版功能、界面相仿。 * 但还不支持键盘操作。 */public class Calculator extends JFrame implements Action...

18141647159:求JAVA计算器源代码!!!
冶克答:f=new JFrame("计算器");p=new Panel();//运算界面p p.setLayout(new GridLayout(4,4)); // 设置p的布局为GridLayout,四行四列 tf=new TextField(30);//实例化按钮 b1=new Button("7");b2=new Button("8");b3=new Button("9");b4=new Button("+");b5=new Button("4");b6...

18141647159:求一份Java编写的计算器
冶克答:求一份Java编写的计算器 20 最近刚接触Java,所以对其还不是很理解。现在需要一份用Java编写的计算器,自己不会做。所以请求会的给个答案。不要很复杂。能运行简单的算法就行了。谢谢各位啦... 最近刚接触Java,所以对其还不是很理解。现在需要一份用Java编写的计算器,自己不会做。所以请求会的给个答案。不要...

(编辑:本站网友)
相关推荐
关于我们 | 客户服务 | 服务条款 | 联系我们 | 免责声明 | 网站地图
@ 百韵网