Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

Wait Cursor stuck in Table Header, bug??

Thread view: 
quelcher@gmail.com - 25 Oct 2007 22:01 GMT
I have a simple JTable on my app.  When new data is loaded into the
app, I turn the cursor into a wait cursor while the data loads in a
separate thread.  Once complete the cursor returns to normal.
However, if the mouse cursor happens to be on the JTable's header
while the cursor is in the 'wait' mode, it appears to get stuck in
that mode.  If I move the cursor off the header it returns to normal,
but then if I put it back on the header it returns to a wait cursor.
Almost as if that section of the screen still thinks it's in wait
mode.  This behavior only occurs when the mouse is on the header while
the cursor is changed.  If it's anywhere else in the app, the cursor
works fine on all areas of the screen after it returns to default.

I've tried this on both Windows and Linux machines with the same
effect.  I'm using Java 1.5.0_04.  I'm using the app's Frame when
switching the cursor back and forth.

appFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
..// load data
appFrame.setCursor(Cursor.getDefaultCursor());

Nothing special about the JTable.  Even turned off my
JTableHeaderRenderer and am using the default, to no effect.

Anyone have any clue what's going on?

Thanks,

Dennis
Daniel Pitts - 25 Oct 2007 22:43 GMT
> I have a simple JTable on my app.  When new data is loaded into the
> app, I turn the cursor into a wait cursor while the data loads in a
[quoted text clipped - 24 lines]
>
> Dennis

Could you provide an SSCCE?
<http://mindprod.com/jgloss/sscce.html>

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

quelcher@gmail.com - 15 Nov 2007 16:33 GMT
Here you go.  I believe the problem stems from the program running in
a separate thread.  When the mouse cursor crosses the separator in the
table header, the cursor will change to a left/right arrow while it's
in the separator.  When it does this (while it's in WAIT_CURSOR mode),
is what I believe is the problem.  Once the cursor changes in the
separator, it's forever stuck in WAIT_CURSOR mode after that.  Can you
verify this before I submit it as a bug?

Thanks,

Dennis

---------------------------------

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

public class Main {

   /** Creates a new instance of Main */
   public Main() {
   }

   private static class RunThread implements Runnable {
       private javax.swing.JFrame mainFrame;
                   public RunThread(javax.swing.JFrame frame)
{ mainFrame = frame; }
                   public void run() {
                   try {

mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                       Thread.sleep(5000);

(mainFrame).setCursor(Cursor.getDefaultCursor());
                       System.out.println("Cursor Should have
Returned to Normal here");
                   }catch(Exception e){} ;
                }
       }
   /**
    * @param args the command line arguments
    */
   public static void main(String[] args) {
       // TODO code application logic here

       final JFrame mainFrame = new JFrame("Test Frame");
       mainFrame.setSize(500,500);
       Container c = mainFrame.getContentPane();
       c.setBackground(Color.GRAY);
       c.setLayout(new FlowLayout());

       // Add JTable
       Object[][] data = {{"row1","row2"}};
       String[] columnName = {"Press Here","Pause in Separator"};

       JTable table = new JTable(data,columnName);
       JTableHeader header = table.getTableHeader();

       mainFrame.addWindowListener(new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
                mainFrame.dispose();
                System.exit(0);
           }
        });

       header.addMouseListener(new java.awt.event.MouseAdapter() {
           public void mouseClicked(java.awt.event.MouseEvent evt) {

               new Thread(new RunThread(mainFrame)).start();
           }
       });

       c.setLayout(new BorderLayout());
       c.add(header,BorderLayout.NORTH);
       c.add(table,BorderLayout.CENTER);

       mainFrame.setVisible(true);
   }

}


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.