BTW hard coding the bounds of the buttons is the wrong way to go, it means your keyboard can't be resized. Use a layout manager to layout the buttons instead. You'll probably need something like GridBagLayout to do a keyboard layout, if you don't know how to use it there are plenty of tutorials on-line.