public void actionPerformed(java.awt.event.ActionEvent e) { JButton b = ( JButton )e.getSource(); String label = b.getText(); //decimal handling //cannot have 2 decimals if (label.equals(".")) { String t1 = display.getText(); if (t1.indexOf(".") == -1) display.setText(t1 + "."); }
However, this still allows for too many decimals, even though I do check for the existence of a decimal via the indexOf method. anyone have any idea why this is happening? The display that I'm displaying to is named display, the rest of the code is correct, I just can't get this decimal thing to work.
Thanks.