Basically I am trying to finish code for a simple GUI number pad and I am having issues with the very last bit. When I click the decimal Button(buttonDot) I want it to drop the default 0 after the decimal point, and then when I press another number button I want it to go where the 0 was.
Thanks for any help you can give me.public class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent arg0) { JButton clickedOn = (JButton)arg0.getSource(); String s=label1.getText(); int length=s.length()-1; int d=0; if(decimal==false) { if(clickedOn == buttonDot) { decimal=true; } else if(label1.getText()=="0.0"){ label1.setText(clickedOn.getText()+".0"); } else { s=label1.getText(); label1.setText(s.substring(0,length1)+clickedOn.getText()+s.substring(length-1,length+1)); d++; } } if(decimal==true) { if(clickedOn == buttonDot) { return; } if(label1.getText().substring(length-1,length)==".0"){ label1.setText(s.substring(0,length-1)+clickedOn.getText()); System.out.println("f"); } else { label1.setText(s+clickedOn.getText()); System.out.println("u"); } } if(clickedOn == clear) { decimal=false; label1.setText("0.0"); } } } }