Article View: borland.public.jbuilder.java.swing
Article #793Newbie paint/upsate question
From: Dean Ware
Date: Sun, 27 Jun 2004 04:40
Date: Sun, 27 Jun 2004 04:40
59 lines
2917 bytes
2917 bytes
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.
Technical Details
Message-ID:
<cblj40$oar$2@sparta.btinternet.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!dedekind.zen.co.uk!zen.net.uk!demorgan.zen.co.uk!194.72.9.35.MISMATCH!news-peer1!btnet-feed3!newreader.ukcore.bt.net!btnet-feed5!btnet!news.btopenworld.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 111d45,13019312cd981286,start X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!dedekind.zen.co.uk!zen.net.uk!demorgan.zen.co.uk!194.72.9.35.MISMATCH!news-peer1!btnet-feed3!newreader.ukcore.bt.net!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: Dean Ware <chocawok@notreal.com> Newsgroups: borland.public.jbuilder.java.swing Subject: Newbie paint/upsate question Date: Sun, 27 Jun 2004 04:40:32 +0000 (UTC) Organization: BT Openworld Lines: 77 Message-ID: <cblj40$oar$2@sparta.btinternet.com> NNTP-Posting-Host: host217-42-84-109.range217-42.btcentralplus.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sparta.btinternet.com 1088311232 24923 217.42.84.109 (27 Jun 2004 04:40:32 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Sun, 27 Jun 2004 04:40:32 +0000 (UTC) X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113