Link to home
Start Free TrialLog in
Avatar of MirecXP
MirecXPFlag for Slovakia

asked on

Distorted Java Graphics

My java gui is distorted.
Does anybody know how to repair it ?
I'm using Matrox graphics card G450 dualhead on Windows 2k platform ..

Distortion looks like this:
http://piencak.host.sk/java/distortion.html
It appears everytime I scroll, after clicking into scrollpane it redraws itself. The problem is in my programs and in JBuilder gui also.

Thanks for help.
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mzimmer74
mzimmer74

I've also ran into this, but just tend to ignore it as I haven't found a good solution yet.  I suppose that what you might be able to do is listen to the scroll bar changing and when it stops call repaint (or revalidate) on the scrollpane.  This might solve your problem.
This is just not a bug.. I can't believe you guys.. "Video Card problems??"

it's a feature of JScrollPane and Tables / Trees..

Basically it's how the graphics are painted:
each row is cached when painted the last row is not neccesarily all visible.

If you debug the paint method you'd find that one of the them last one painted has a very small height than the others "an obvious feature yes".

I'm not to fond either. but there is a work around and this is what took the time. Working out the relationship between JTable the UI, and the ScrollPanel.

The table has special code along with the tree, it acts differently when in a JScrollPane :(

it's a one line fix that in my opinion is worth more than 40 measily points
scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);

there are two other options
public static final int BLIT_SCROLL_MODE = 1;
public static final int BACKINGSTORE_SCROLL_MODE = 2;

I recommend you to use the SIMPLE_SCROLL if you haven't got a lot of paint to do..  BLIT was awful for me, BACKINGSTORE didn't work well for me either.

Regards

Keith Long
www.technogenius.co.uk
> This is just not a bug.. I can't believe you
> guys.. "Video Card problems??"

Then why doesn't it occur on all machines??

> Basically it's how the graphics are painted

So all scrolled graphics are painted incorrectly??
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MirecXP

ASKER

This time I'm using JDK 1.4, which doesn't seem to be buggy in this way.

I've tried your suggestions, Keithlong, it works fine, it seems BLIT_SCROLL_MODE has bug related to the video card (as Objects has said). The other two modes (backing-store and simple) are working well.

Although offerring nice workaround I'd like to leave this question open, because your answer solves problems of my programs, but not the problem with other programs, which are distributed without sources. (JBuilder 6, for example)

Regards, Mirec.
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- split points between keithlong and objects

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
Avatar of MirecXP

ASKER

I have also encountered this problem with many others Matrox video cards.