S
Stupid Dustbin
Hi, I'm currently doing an application which users drag and drop
graphical items on a canvas and drag them around the canvas. I have
always wondered if I should extends JComponent or should I not to for
this task.
I don't know much about JComponent though.
My current implementation is to just make the canvas (a JPanel)
implements MouseMotionListener and Mouse Listener, and keep a list of
items on the canvas and when my mouse is pressed, it just loop through
the list of items and check if it is selected and set it as the
selected item so that when I drag my mouse, the selected item move
too.
Didn't make my item class extends JComponent in this implementation.
The application is working fine but I decide to ask about this since
it is something I thought for a long time and my school teacher say I
probably should extends JComponent which I'm not sure why.
graphical items on a canvas and drag them around the canvas. I have
always wondered if I should extends JComponent or should I not to for
this task.
I don't know much about JComponent though.
My current implementation is to just make the canvas (a JPanel)
implements MouseMotionListener and Mouse Listener, and keep a list of
items on the canvas and when my mouse is pressed, it just loop through
the list of items and check if it is selected and set it as the
selected item so that when I drag my mouse, the selected item move
too.
Didn't make my item class extends JComponent in this implementation.
The application is working fine but I decide to ask about this since
it is something I thought for a long time and my school teacher say I
probably should extends JComponent which I'm not sure why.