Solved

JScrollPane painting problem with multiple screens

Posted on 2004-04-08
10
282 Views
Last Modified: 2008-03-17
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 );

      }
}
0
Comment
Question by:amswain
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 30

Expert Comment

by:mayankeagle
ID: 10782338
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
0
 
LVL 1

Author Comment

by:amswain
ID: 10782399
a) No effect (and why would it)?  b) It's only a test program and I'm a lazy typist.
0
 
LVL 1

Author Comment

by:amswain
ID: 10782408
BTW, I have also tried running with
-Dsun.java2d.ddlock=true and
-Dsun.java2d.noddraw=true
with no improvement
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 10782421
>>  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?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10785159
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?
0
 
LVL 92

Expert Comment

by:objects
ID: 10787583
Sounds like potentially a java bug with that card.
0
 
LVL 1

Author Comment

by:amswain
ID: 10811509
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?
0
 
LVL 92

Expert Comment

by:objects
ID: 10817904
report them to sun.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11081046
PAQed, with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now