Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #563

Re: View update synch pro

From "Steve W. Jackson" <steve.w..jackson@THRWHITE.remove-dii-this>
Subject Re: View update synch pro
Message-ID <stevewjackson-39A7DB.12151404012007@individual.net> (permalink)
Newsgroups comp.lang.java.gui
References <l0qv64-akn.ln1@bealzebub.pandemonium>
Date 2011-04-27 15:28 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
In article <l0qv64-akn.ln1@bealzebub.pandemonium>,
 Jim <JimTheBad@NTLWorld.com> wrote:

> Steve W. Jackson wrote:
> 
> > In article <p7fv64-q4n.ln1@bealzebub.pandemonium>,
> >  Jim <JimTheBad@NTLWorld.com> wrote:
> > 
> [snip]
> 
> Hmm, good answer. You may have guessed I come from a C++ background and am
> fairly new to java. Hence the lack of adherence to conventions. :)
> 
> SelectCity() doesn't actually do any drawing - it reads the database and
> decides what should be drawn, although it does add/remove components and
> such.
> 
> I don't ever call paint() directly. I have overloaded it (is this the java
> term?) to do the actual drawing.
> 
> I really like your idea of drawing to an off-screen buffer. So you suggest
> that SelectCity() should read the data AND draw it to a buffer, and the
> overloaded paint func^H^H^H^H method should merely paint the buffered image
> to the screen. Yeah, I can see the logic in that. 
> 
> Thanks mate.
> Jim

My preferred environment before Java was C, so I too had the long 
ingrained habit of saying "function" instead of "method."  I never did 
much C++, so I don't know whether the OO aspect would've caused any 
shift or not.  :-)

I may have misread the original post and simply *assumed* that your 
SelectCity code was drawing.  On re-reading, I see that you said only 
that it determines what was to be displayed and that paint() "renders 
the view".  Apologies if I misinterpreted.

But the off-screen buffer concept that I described is what we use in our 
application, and I've learned a great deal about its advantage over the 
time I've been working with it.  Ours is a modeling and simulation 
application that maintains its "model" in an XML document.  As user 
actions and other things occur, they result in the firing of property 
change events that cause the BufferedImage to get redrawn.  Any time 
that buffer gets changed, the code that does so will also invoke 
repaint() on the corresponding JPanel.  When the system determines a 
need to paint that same panel, it ultimately does the same.  The result 
is that the paintComponent code does little more than simply draw 
whatever is currently in the BufferedImage onto the Graphics object 
which is provided as a parameter to the paintComponent method.

Hope I was able to help.

= Steve =
-- 
Steve W. Jackson
Montgomery, Alabama

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | Next | Find similar


Thread

Re: View update synch pro "Steve W. Jackson" <steve.w..jackson@THRWHITE.remove-dii-this> - 2011-04-27 15:28 +0000

csiph-web