Solved

JScrollPane painting problem with multiple screens

Posted on 2004-04-08
10
288 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:Mayank S
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:Mayank S
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Systems talking to each other 5 126
Java asynchronous logging 4 50
eclipse compiler vs Installed JREs option 3 77
starter POM and spring-boot-starter,  spring-boot-web 2 43
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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

863 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

18 Experts available now in Live!

Get 1:1 Help Now