Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4357115

JTableHeader is overriding parent’s cursor after a resize cursor is displa

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0
    • client-libs
    • beta
    • x86
    • windows_nt



      Name: skT45625 Date: 07/27/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      It appears that after the JTableHeader displays a resize cursor it is forcing
      the cursor to DEFAULT_CURSOR. This prevents the header from displaying the
      cursor that is set on its parent. We have code that sets the cursor to a wait
      cursor on the JFrame that contains a JTable when the user clicks on a column
      header to sort the data in the table. The code works fine until the user puts
      the cursor over the divider between columns and the resize cursor is
      displayed. After that when the wait cursor is set on the JFrame, it does not
      affect the cursor over the header. It acts like the cursor is being forced to
      DEFAULT_CURSOR instead of being set to null when the resize is complete,
      preventing the parent’s cursor setting from affecting it.

      The following code will demonstrate the problem:

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

      public class TableTest extends JFrame
      {
          JTable table = null;
          static TableTest test = null;

          public TableTest()
          {
              Object[][] data = {};

              String[] columnNames = {"First Name",
                                      "Last Name",
                                      "Sport",
                                      "# of Years",
                                      "Vegetarian"};

              table = new JTable(data, columnNames);
              MouseListener busyCursor = new BusyListener();
              table.getTableHeader().addMouseListener( busyCursor );
              JScrollPane scrollPane = new JScrollPane(table);
              getContentPane().add( scrollPane );
              setDefaultCloseOperation( EXIT_ON_CLOSE );
              pack();
      }

      class BusyListener extends MouseAdapter {
          public void mouseReleased(MouseEvent e) {
              makeBusy(e);
          }

          void makeBusy(MouseEvent e)
          {
             //table.getTableHeader().setCursor( null );
             test.setCursor( java.awt.Cursor.getPredefinedCursor(
      java.awt.Cursor.WAIT_CURSOR) );
             try {
             Thread.sleep( 500 );
             } catch ( InterruptedException ie ) { }
             test.setCursor( null );
          }
      }

          public static void main( String[] args )
          {
              test = new TableTest();
              test.setVisible( true );
          }
      }


      When you click on a column header it will make the cursor a wait cursor for 1/2
      second, then reset it. It works fine until you get between columns and the
      resize cursor displays. If you uncomment the first line in makeBusy() it will
      continue to work after the resize cursor is displayed.
      (Review ID: 107675)
      ======================================================================

            pmilnesunw Philip Milne (Inactive)
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: