| David Vanderschel 2005-06-10, 4:02 pm |
| There is some strangeness regarding graphics contexts
which I do not understand, and I am hoping that
someone can figure out what I am missing. (FWIW, I am
using the 1.4 JDK because I am still working under
Windows 98.)
1. I have an extended JPanel for which my program does
all the drawing. Let's call it "myPane". When I
get the paintComponent() callback for myPane and
use the graphics context passed as the argument to
that method, all works as expected. However, if
I do a myPane.getGraphics() and use the context
returned by the getGraphics() method, things do not
work as expected. In particular, redrawing does
not occur when it is supposed to. I do not
understand the difference in behaviour with the
graphics context for myPane coming via these
different routes.
2. If I pass a clip rectangle when I invoke
myPane.repaint(), the clip rectangle works as
expected during the drawing. I had a couple things
I wanted to draw outside the clip rectangle. When
I attempt to set a new (full pane) clip rectangle
during my drawing process in order to add these
extra things, it does not work. The original
clipping rectangle appears still to be in effect.
Why? (Meanwhile, I have had to give up the
efficiency consideration which led me to use the
clip rectangle in the first place.)
3. myPane exists in a split pane component of a
JFrame. If I do frame.setSize() to alter the shape
of the frame, the split pane and myPane within it
do not reconfigure their size to fit the new frame
in the manner that they do when I manually resize
the frame using the mouse. Ie., when
paintComponent is called and I invoke getSize() on
myPane, I get its old size, not a size which fits
in the resized frame. How can I make the
reconfiguration of components in the frame occur as
when a user modifies the size of the frame using
the GUI?
Thanks for any pointers,
David V.8
|