Link to home
Start Free TrialLog in
Avatar of amswain
amswain

asked on

JScrollPane painting problem with multiple screens

I have a JTable inside a JScrollPane.  When the frame is stretched across more than one screen and the vertical scrollbar is moved, only the portion of the table on the left screen gets repainted properly.

I am running Windows XP professional, matrox g200 multi-monitor.  I have tried this with jdk1.3.1_11 and j2sdk1.4.2_04.  Both have the same problem.

I can't be 100% sure, but I don't think we had this problem when running with Windows NT across multiple screens.

Any suggestions please?


import java.awt.*;
import javax.swing.*;


class TestTable {


      public static void main( String[] args ) throws Exception {
            Object[][] data = new Object[100][100];
            String[] cols = new String[100];

            for (int i=0; i<100; i++) {
                  cols[i] = String.valueOf( 'A'+i );
                  for (int j=0; j<100; j++) {
                        data[i][j] = String.valueOf( 'A'+i );
                  }
            }

            JTable t = new JTable( data, cols );
            JScrollPane sp = new JScrollPane( t );

            JFrame f = new JFrame();
            f.getContentPane().add( sp );
            f.pack();
            f.show();
            f.setDefaultCloseOperation( f.EXIT_ON_CLOSE );

      }
}
Avatar of Mayank S
Mayank S
Flag of India image

Try adding your JScrollPane to a JPanel first and then add the JPanel to the JFrame. See if that helps.

>> f.setDefaultCloseOperation( f.EXIT_ON_CLOSE );

- the better way to call it would be:

f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE ) ; // EXIT_ON_CLOSE is static
Avatar of amswain
amswain

ASKER

a) No effect (and why would it)?  b) It's only a test program and I'm a lazy typist.
Avatar of amswain

ASKER

BTW, I have also tried running with
-Dsun.java2d.ddlock=true and
-Dsun.java2d.noddraw=true
with no improvement
>>  why would it

'coz in some cases, putting a JPanel is often very useful.

>> It's only a test program and I'm a lazy typist

You can copy-paste. BTW, in the original program, what is the layout that you have?
I have tested your code on my machine, and i don't have any refresh problems.
GF4 MX460 spanning accross my CRT monitor and my TV.
Using j2se 1.4.2_01 and WinXP.
It looks like java sends messages that are not relayed by the multi-screen driver.
Java might be using native commands that are not supported by the driver???
Do you have the latest driver installed for your Matrox?
Sounds like potentially a java bug with that card.
Avatar of amswain

ASKER

I have found another bug which I think is related.  Running the same program (above) with this small change

            JTable t = new JTable( data, cols ) {
                  public String getToolTipText( MouseEvent e ) {
                        int r = rowAtPoint( e.getPoint() );
                        int c = columnAtPoint( e.getPoint() );
                        Object value = getValueAt( r, c );
                        return value==null ? null : value.toString();
                  }
            };

with the table stretched across multiple screens, the tooltip always appears on the left screen, even when the mouse is over the table in the right hand screen (the tooltip appears at the far right of the first screen).

Should I be reporting these bugs on the java site or with matrox?
report them to sun.
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

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