Hi there!
I've been struggling for a couple of hours to achieve something pretty simple.
I need to get a custom painting Panel which has many shapes and a field in which I'm displaying the name of the shape that has been mouse over'ed( mouseEntered event).
My design is very clumsy.
First I will explain how I thought I could design this and then add the code below.
Well, I thought I should use inheritance since I have many figures that are shapes.
Every shape will be painted in a different paint Panel(many classes that extends JPanel) so I can control them individually. I thought I could make the superclass extends JPanel and then override paintComponent(Graphics g) method in each and every subclass I already have or will add in the future.
I will also need an MouseListener for every shape so like the above scenario, I thought I could make the superclass implement MouseListener and override itself the methods I don't need in my subclasses...and in my subclasses I only need mouseEntered event( equivalent to mouse over).
But here arises the problems: Where will the frame be created and all the panels that will be added to the frame...I used gridlayout for the frame's layout so I can add multiple paint Panels!
Then...how on earth should I make to get the field in the mouseEntered() method of every subclass and also in the class where I'm creating the frame, an auxiliary class!
This is my code...please tell me what am I wrong...thanks in advance!!
As you can see, there are only 3 shapes but many other could be added due to inheritance...Don't ask me why I've used an abstract class which I cannot instantiate...I'm just at the beginning...please tell me all the big mistakes I made...and how can I make that textfield be visible in the subclasses as well as the auxiliary class. Thanks in advance