bom dia, seguinte pessoal estou fazendo uma calc em java usando interface grafica, gostaria de saber como faço para minha calc somar subtrair etc... sem depender do botao igual (=) ex: da minha calc : 2 + 4 (aperto = )6 + 4 (aperto = )10 ex como eu queria q fosse : 2+4+(aparecesse 6)+4(aparecesse 10) e assim por diante agradeço desde de já!! segue meu codigo import javax.swing.*; import java.awt.event.*; import java.awt.Color; class Calc extends JFrame implements ActionListener{ //crio os objetos dos botoes JTextField visor=new JTextField(16); JButton b7=new JButton("7"); JButton b8=new JButton("8"); JButton b9=new JButton("9"); JButton bmulti=new JButton("*"); JButton b4=new JButton("4"); JButton b5=new JButton("5"); JButton b6=new JButton("6"); JButton bdiv=new JButton("/"); JButton b1=new JButton("1"); JButton b2=new JButton("2"); JButton b3=new JButton("3"); JButton bsub=new JButton("-"); JButton b0=new JButton("0"); JButton blimpa=new JButton("C"); JButton bigual=new JButton("="); JButton bsoma=new JButton("+"); String op=""; Double conta=0.0; Double guarda=0.0; Calc() { //definiçoes da minha interface setTitle("Calculadora"); setBounds(500,200,230,230); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p=new JPanel(); //adiciono os botoes ao actionListener b7.addActionListener(this); b8.addActionListener(this); b9.addActionListener(this); b4.addActionListener(this); b5.addActionListener(this); b6.addActionListener(this); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b0.addActionListener(this); blimpa.addActionListener(this); bigual.addActionListener(this); bsoma.addActionListener(this); bsub.addActionListener(this); bmulti.addActionListener(this); bdiv.addActionListener(this); //adiciono os botoes no painel p.add(visor); visor.setHorizontalAlignment(JTextField.RIGHT); visor.setEditable(false); visor.setForeground(Color.blue); setResizable(false); p.add(b7); b7.setBackground(Color.black); b7.setForeground(Color.white); p.add(b8); b8.setBackground(Color.black); b8.setForeground(Color.white); p.add(b9); b9.setBackground(Color.black); b9.setForeground(Color.white); p.add(bmulti); bmulti.setBackground(Color.black); bmulti.setForeground(Color.white); p.add(b4); b4.setBackground(Color.black); b4.setForeground(Color.white); p.add(b5); b5.setBackground(Color.black); b5.setForeground(Color.white); p.add(b6); b6.setBackground(Color.black); b6.setForeground(Color.white); p.add(bdiv); bdiv.setBackground(Color.black); bdiv.setForeground(Color.white); p.add(b1); b1.setBackground(Color.black); b1.setForeground(Color.white); p.add(b2); b2.setBackground(Color.black); b2.setForeground(Color.white); p.add(b3); b3.setBackground(Color.black); b3.setForeground(Color.white); p.add(bsub); bsub.setBackground(Color.black); bsub.setForeground(Color.white); p.add(b0); b0.setBackground(Color.black); b0.setForeground(Color.white); p.add(blimpa); blimpa.setBackground(Color.black); blimpa.setForeground(Color.white); p.add(bigual); bigual.setBackground(Color.black); bigual.setForeground(Color.white); p.add(bsoma); bsoma.setBackground(Color.black); bsoma.setForeground(Color.white); setContentPane(p); setVisible(true); } public void actionPerformed(ActionEvent e) { //ações aos botoes if(e.getSource()==b7) { visor.setText(visor.getText()+7); } if(e.getSource()==b8) { visor.setText(visor.getText()+8); } if(e.getSource()==b9) { visor.setText(visor.getText()+9); } if(e.getSource()==b4) { visor.setText(visor.getText()+4); } if(e.getSource()==b5) { visor.setText(visor.getText()+5); } if(e.getSource()==b6) { visor.setText(visor.getText()+6); } if(e.getSource()==b1) { visor.setText(visor.getText()+1); } if(e.getSource()==b2) { visor.setText(visor.getText()+2); } if(e.getSource()==b3) { visor.setText(visor.getText()+3); } if(e.getSource()==b0) { visor.setText(visor.getText()+0); } if(e.getSource()==blimpa) { visor.setText(""); } //defino as operações aos botões double aux; if(visor.getText().equals("")) { aux=0; } else { aux=Double.parseDouble(visor.getText()); } if(e.getSource()==bsoma) { visor.setText(""); guarda=aux; op="+"; } if(e.getSource()==bsub) { visor.setText(""); guarda=aux; op="-"; } if(e.getSource()==bmulti) { visor.setText(""); guarda=aux; op="*"; } if(e.getSource()==bdiv) { visor.setText(""); guarda=aux; op="/"; } //faço as operaçoes aos botoes if(e.getSource()==bigual) { if (op== "+") { conta= guarda+aux; visor.setText("" + conta); } if (op== "-") { conta= guarda-aux; visor.setText("" + conta); } if (op== "*") { conta= guarda*aux; visor.setText("" + conta); } if (op== "/") { if(aux==0) { visor.setText(""+ "erro"); } else { conta= guarda/aux; visor.setText("" + conta); } } } } public static void main(String[]args) { Calc c=new Calc(); } }