I'm doing a small calculator using JLabel and I'm asking how to substring a JLabel,
public class plusListener implements ActionListener {
public void actionPerformed (ActionEvent event){
s1 = label.getText();
d1 = Double.parseDouble(s1);
int x = s1.indexOf("+");
label.setText(label.getText() +" + ");
}
}
So what I'm trying to do is to let the JLabel print the numbers I'm typing and at the same time calculate it, for example i want 5 + 2, so the JLabel would print 5 + 2 = 7
But my main problem here is that I'm stuck at saving the second number to calculate it.