我有一个计算器的内部JFrame。 我需要在计算器上计算一个值,当我从同一个类(不在JFrame中)中单击TOTAL按钮时,它应该在TOTAL的文本字段中显示相同的值。我怎样才能做到这一点?我使用Java eclipse。
我的按钮计算器代码:
btnCalc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Calculator frame = new Calculator();
frame.setVisible(true);
frame.setBounds(555, 70, 395, 260);
getContentPane().add(frame);
}
});
将数字放入文本字段计算器:
twoText = textField.getText() + two.getText();