Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Listener, Component, Interface  RSS feed

 
Mike Cole
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

first question is it acceptable to have more than one mouseListener?

2nd.:

Iam trying to prog. a simple game. In the game there are items.(a abstract class called Item). Item is really just the idea of an item, from it i subclass all the real items. -> spoon, screwdriver, flask and so on.
Now i want to make them "selectable", that means, if i move my mouse over an item it should change the graphics(like a button). The graphical representation of such an item is stored in a Class called Sprite. Which itself contains the images and some extra data. Now i found out that there is a class called Component and some interfaces called Accesible*.
My first idea was to subclass my Item class from Component and then add a mouse-listener to it, that way i thought i could find out when an object should be selected. The problem now is... i allready have a mouse-listener which does check other things...and/but only this one works.
So for my 2nd Question... is it a good idea to make my Item a subclass of Component? Or should i write something completly new? In a Component there are so many functions, i dont belive that i ever gonna need half of them.
Do i need any "accesible"-interfaces to reach my goal?(Iam confused by the amount of classes and interfaces java offers). Should i use JComponent or normal Component? Does that idea work? I wish to keep the Item class and Sprite class strictly seperated. (btw. Sprite contains BufferedImage which is drawn onto a Canvas, i hope that doesen�t destroy the idea of components)

Thank you very, very much!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!