is there code in java to process a certain code only while a button is pressed once its released the code stops executuing
well u can use on press command or u can use event delegation model and use MOUSE LISTENER interface, usin' which u can use mouseclick function over the coordinates of the button, which u can get usin' getx and gety function for the position of the button.
absolutely! You have the events of onPress and onRelease. use 'em.