Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2004

Tip: Looking for answers? Try searching our database.

Newbie SWING repiant/update question

Thread view: 
Dean Ware - 27 Jun 2004 05:39 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.