posted 8 years ago
in this case overriding 'paint' is acceptable, I think. Given the code, it is unlikely
that 'paintBorder' and 'paintChildren' are necessary. Clearing the component
to the background is needed, indeed, but that can be done with a simple 'g.fill'.
But I wonder: isn't it much simpler if Drawrea extends JPanel? Internally,
the pixels can be written to a BufferedImage, and the 'paintComponent'
of the panel simply draws that BufferedImage, even when a drag
is going on.
Add a method 'getImage' that returns the BI, for the cases that
you need it. It also has the advantage that there is no need
for a huge Point array. I would advise a List<Point> anyway.
However, special attention is needed when DrawArea is getting resized.
Since it is a JComponent, it is subject to the resizing policy of the
Layoutmanager of the container involved.
@Dongolo
have you thought about resizing aspects?
There are three kinds of actuaries: those who can count, and those who can't.