[Advanced-java] window refresh question

Alvin Wang xwang at qtechservices.com
Mon Apr 14 14:36:31 2003


Expert/Guru Nikolaos :
1. I am not a designer of the app. it is out of my hand.
2. without knowing the details of the biz requirement and the design, pls do
not assume yourself the one that can teach others regarding their app design
3. i did not remember i asked that question mentioned by u. i searched my
inbox and only found an email from you and i put it at the end of this email
as a reminder. (thx for that email again. it is a good hint)

> -----Original Message-----
> From: advanced-java-bounces@lists.xcf.berkeley.edu
> [mailto:advanced-java-bounces@lists.xcf.berkeley.edu]On Behalf Of
> Nikolaos Giannopoulos
> Sent: Sunday, April 13, 2003 10:30 AM
> To: Alvin Wang
> Cc: advanced-java@lists.xcf.berkeley.edu
> Subject: RE: [Advanced-java] window refresh question
>
>
> > -----Original Message-----
> > From: advanced-java-bounces@lists.xcf.berkeley.edu
> > [mailto:advanced-java-bounces@lists.xcf.berkeley.edu]On Behalf Of Alvin
> > Wang
> >
> >
> > Hi, I am writing a multi-window Java application. It receives
> > huge amount of
> > data from network and displays in JTables. So basically, it is
> > swamped. When
> > the users moves the windows, it does not have time to handle the repaint
> > events, so the screen smears.
>
> I seem to remember a couple months back that you asked a qustion about
> populating a JTable with > 10,000 rows (or something thereof).  You
> obviously didn't listen to the advice that I offered... maybe once you
> realize your only digging a deaper hole you might stop and listen.
>
>
> > In X-Windows, we can suppress the window events, which means the
> > application
>
> This is a kludge that does not address the real problem at hand
> AND in this
> case IMO never will.
>
>
> > will drop some events if it sees itself far behind. The other way in
> > X-Windows is the server can save-behind, which means instead of
> trying to
> > repaint some area, it will save that area for future repaint event.
>
> Same comment.  No kludge will work well enough unless you address the real
> problem with your app and that is in having huge amounts of server data
> streamed to your tables NOT to mention that:
>
> (a) your flooding your network unnecessarily,
> (b) your over-working your server unnecessarily and
> (c) your application will not scale NO matter how much hardware
> you throw at
> it.
>
>
> > I am not a GUI expert.
>
> That is quite clear.
>
>
> > Can any guru give me some suggestions how
>
> You have been given them.  Re-design your app to filter the amount of data
> that is sent to the gui.  Alternatively let the server do the
> work for you -
> i.e. pass it criteria to obtain a smaller set of rows.
>
> It seems like you want to move large amounts of data from a back-end
> database to the client *assuming* that you are going to get better
> performance because you have all the data offhand.  Which is exactly the
> wrong thing to do most of the time as you may have instant access to your
> data but *have fun* trying to display things to your user (as you are
> seeing) amongst other problems like (a), (b), and (c) above.
>
> Just imagine how silly it would be if in doing a search on google - you
> first had to dowload their entire database - and you might see
> your problem.
>
>
> > to improve
> > in Java world, or acheive similar strategies I described above in Java?
>
> Your design will fail in pretty much any language you code it in i.e. You
> need to understand this is NOT a language or gui problem, rather
> your issue
> is a fundamental design issue.
>
> Cut your losses.  Fix the design and you won't have to worry about the
> questions you raised in this post.
>
> --Nikolaos
>
>
> _______________________________________________
> Advanced-java mailing list
> Advanced-java@lists.xcf.berkeley.edu
> http://lists.xcf.berkeley.edu/mailman/listinfo/advanced-java


----------------------
I imagine you can center the row by grabbing the select rectangle and then
centering it in the view port.

Here's some code that vertically centers the cursor in a text pane to be in
the center of the text pane.

  Rectangle cursorRect, viewRect;
  cursorRect = text.modelToView(cursorOffset);
  viewRect = text.getVisibleRect();
  viewRect.setLocation(
      cursorRect.x, cursorRect.y - (int) (viewRect.height / 2));
  text.scrollRectToVisible(viewRect);

I imagine you should be able to adapt the code quite easily to your needs.

BTW to be fair to Lorin you never asked for this behaviour and thus his
answer was sufficient for your original post.

--NIkolaos

> > -----Original Message-----
> > From: Alvin Wang [mailto:xwang@qtechservices.com]
> > Sent: Tuesday, March 04, 2003 12:19 PM
> > To: advanced-java@lists.xcf.berkeley.edu
> > Subject: [Advanced-java] How to scroll JTable in code?
> >
> >
> > Hi, in my code, I want to scroll a JTable (in a JScrollPane) to
> a specific
> > row. Can anyone tell me how to do this? thanks!
> >
> > Alvin
> >