View RSS Feed

Java AWT

Java Abstract Window Toolkit (AWT)

  1. Supporting User Interaction

    by , 03-06-2012 at 08:41 PM
    User interaction is supported with the graphics you want to display. You need to be able to determine when the user clicks on one of them. To determine whether a mouse click occurred over a particular Shape object, The Graphics2D class provides a hit method. You can also get the location of the mouse click. Call the contains method on the Shape class to determine whether the click was within the bounds of the Shape.

    You can perform simple hit testing, if you are using primitive text ...