Ted Hill wrote:
>
> Hello,
>
> I am creating a panel (extending JPanel) which will display a BufferedImage.
>
> In each corner of the JPanel I want to place a control. That is, the
> controls will be painted inside the JPanel on top of the BufferedImage.
>
> One alternative would be to use Shapes as my controls and use the
> Graphics2D.hit( ) method inside the panel's MouseListener.
>
> However, I would prefer something more object-oriented, that is, I would to
> build a control class that:
>
> 1) would take the Panel's Graphics2D as a parameter so that it could draw
> itself on the panel.
>
> 2) would have its own MouseListener so that it could respond to left and
> right clicks, drags, etc.
>
> Can someone suggest a good design strategy?

Since the JPanel is the underlying container in your proposed design you could
very easily use JButton as the component for your "control" buttons.  If you
need the button to look like something other than the standard JButton, simply
create some gif images as button faces.

Adding the buttons to your JPanel is as uncomplicated as using a layout manager
that places the buttons where you need them, and then let Java do the painting.
Naturally, if you need custom MouseListeners, you'll have to write those, but
they're easily attached to the button controls you need.

This is not just theory as I have had good success doing precisely what you
want to do using the methods I've just described.

--
John Thienes                         `Agios `o Theos.
Mentor Graphics Corp.                `Agios Ischuros.
(503) 685-1847                       `Agios Athanatos.
[EMAIL PROTECTED]                  Eleison `emas.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to