Você está usando algum listener para o mouse? tipo MouseListener, ou MouseMotionListener? Se for o caso, será que em algum lugar você não faz seuTextField.setEditable(false); ou seuTextField.setEnabled(false); ? Não sei bem como está sua aplicação, mas se for como estou pensando, não há necessidade de usar eventos de mouse…
Estou postando um código que - imagino - se assemelha à sua aplicação, porém sem esse erro. Se não resolver seu problema, você posta aqui novamente.
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
/**
* br.ufpe.cin
* @author Ernani
*/
public class Calculadora extends JFrame implements ActionListener {
private JPanel fundo;
private JButton soma;
private JButton subtracao;
private JButton multiplicacao;
private JButton divisao;
private JButton resultado;
private JLabel buffer;
private JTextField campo;
private int valor;
public Calculadora() {
super(".::Calculadora");
this.setBounds(100, 100, 300, 170);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().setLayout(null);
this.setResizable(false);
//INICIA O FUNDO
this.fundo = new JPanel(null);
this.fundo.setBounds(0, 0, 300, 170);
this.fundo.setBackground(new Color(200, 200, 200));
this.getContentPane().add(this.fundo);
//INICIA OS COMPONENTES INTERNOS
this.soma = new JButton("ADIÇÃO(+)");
this.subtracao = new JButton("SUBTRAÇÃO(-)");
this.multiplicacao = new JButton("MULTIP.(x)");
this.divisao = new JButton("DIVISÃO(/)");
this.resultado = new JButton("=");
this.campo = new JTextField();
this.buffer = new JLabel("Valor = 0");
this.campo.setHorizontalAlignment(SwingConstants.RIGHT);
//ADICIONA OS COMPONENTES INTERNOS
this.fundo.add(this.soma);
this.fundo.add(this.subtracao);
this.fundo.add(this.multiplicacao);
this.fundo.add(this.divisao);
this.fundo.add(this.resultado);
this.fundo.add(this.campo);
this.fundo.add(this.buffer);
//CONFIGURA OS COMPONENTES INTERNOS
this.soma.setBounds(10, 40, 135, 20);
this.subtracao.setBounds(155, 40, 135, 20);
this.multiplicacao.setBounds(10, 70, 135, 20);
this.divisao.setBounds(155, 70, 135, 20);
this.resultado.setBounds(125, 100, 50, 20);
this.campo.setBounds(10, 10, 280, 20);
this.buffer.setBounds(10, 100, 100, 20);
//ADICIONA OS LISTENERS
this.soma.addActionListener(this);
this.subtracao.addActionListener(this);
this.multiplicacao.addActionListener(this);
this.divisao.addActionListener(this);
this.resultado.addActionListener(this);
//FAZ A JANELA APARECER
this.setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
JButton temp = (JButton) ae.getSource();
if(temp == this.soma) {
this.valor += Integer.parseInt(this.campo.getText());
this.campo.setText("");
} else if(temp == this.subtracao) {
this.valor -= Integer.parseInt(this.campo.getText());
this.campo.setText("");
}else if(temp == this.multiplicacao) {
this.valor *= Integer.parseInt(this.campo.getText());
this.campo.setText("");
}else if(temp == this.divisao) {
this.valor /= Integer.parseInt(this.campo.getText());
this.campo.setText("");
}else if(temp == this.resultado) {
int er = Integer.parseInt(this.campo.getText()) + this.valor;
this.campo.setText(""+er);
this.valor = 0;
}
this.buffer.setText("Valor = " + this.valor);
}
public static void main(String[] args) {
Calculadora c = new Calculadora();
}
}
o código não está perfeito, como você vai perceber, mas se você não forçar erros vai aparecer bem o resultado.
espero ter ajudado