Hi, I'm building a simple image maniplulation program.
I am putting an ImageCanvas object inside a Scrollpane. An imageCanvas
is just an "extended" canvas. I then put this scrolpane inside a
Jtabbedpane.
Thing is, I am doing things with the image but the changes are not
updated immediately. They only take effect after I either switch tabs or
minimise/maximise the window.
This leads me to believe it is a painting/updating problem.
I am a newbie, and this is my first Java GUI.
Below is where I am trying to get the image to update(setMagnification
is where the image gets resized):
public void mousePressed(MouseEvent e) {
myImageCanvas1.setMagnification(2);
myImageCanvas1.update(myImageCanvas1.getGraphics());
myscrollpane1.update(myscrollpane1.getGraphics());
myImagePanel.updateUI();
myImageCanvas1.validate();
myscrollpane1.validate();
myImagePanel.validate();
myImageCanvas1.invalidate();
myscrollpane1.invalidate();
myImagePanel.invalidate();
myImageCanvas1.repaint();
myscrollpane1.repaint();
myImagePanel.repaint();
parent.update(parent.getGraphics());
}
This is just the latest version of the code. I have tried paint() and
repaint() plus invalidate() for ALL objects.
You will notice the "parent" object. This I added as desperation. I
passed parent (which is the Jtabbedpane inside a frame) to the
"ImageCanvas" object in the thought that perhaps the parent needded to
be repainted too.
DIDN'T WORK.
As I say, closing and reopening the window make everything resize and work.
I am obviously missing something here. Looked on google but found nothing.
ANY ideas??
Thanks
"a frustrated" Choca.
Christophe Vanfleteren - 27 Jun 2004 08:12 GMT
> Hi, I'm building a simple image maniplulation program.
>
[quoted text clipped - 55 lines]
>
> "a frustrated" Choca.
It sounds like you're mixing Swing and AWT widgets together. This doesn't
work most of the time.
Use a JComponent or JPanel instead of the Canvas.

Signature
Kind regards,
Christophe Vanfleteren