Lab 13 Solution



Recreate the screenshot below. For reference, the frame is 300 x 300 pixels. The number display is in a different panel than the number buttons (along with the C and “. Buttons).

I have provided the initial setup, along with the numberDisplay JLabel. You must provide the rest.

Functional Requirements

Whenever a button is pushed, you should append the label of the button onto the numberDisplay label. There are a few restrictions though.

Leading zeroes should be ignored. If your first click is 2”, the numberDisplay should show 2”, not 02”. If your first click is 0”, the number display should remain 0 and not change to 00”.

You should only allow one dot to be entered. If 3.22 is in the numberDisplay, you should be able to show “3.22.”

Pressing the C button will reset the text back to 0”.

When complete, show your TA to be marked off for the lab. Below are some example runs. Note, these are all entered with out ever restarting the program. I used the “C button to reset the text.

Image missing


Enter .369

Hit C

Enter 500.369