AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Newbie SWING repiant/update question

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Dean Ware
Guest





PostPosted: Sun Jun 27, 2004 4:39 am    Post subject: Newbie SWING repiant/update question Reply with quote



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.

















Back to top
Christophe Vanfleteren
Guest





PostPosted: Sun Jun 27, 2004 7:12 am    Post subject: Re: Newbie SWING repiant/update question Reply with quote



Dean Ware wrote:

Quote:
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.

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.

--
Kind regards,
Christophe Vanfleteren

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.