craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > General QuickTable Support/Help Post New Topic   Post A Reply
Can't set cursor when clicking table header printer friendly version
next newest post | next oldest post
Author Messages
converge
Corporal

Gender: Unspecified
Location:
Registered: Apr 2004
Status: Offline
Posts: 28

Click here to see the profile for converge Send email to converge Send private message to converge Find more posts by converge Edit or delete this message Reply w/Quote
Posted Tuesday, October 21, 2008 @ 14:39:28  

I'm trying to change the cursor when the user clicks on a column (table header). This seems to only work some of the times, randomly, with no rhyme or reason. Here is my code:

Code:

dbtResults.getTableHeader().addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
Thread.sleep(2000);
} catch (Exception e) {}
setCursor(Cursor.getDefaultCursor());
}

public void mouseReleased(MouseEvent evt) {}
});

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Tuesday, October 21, 2008 @ 16:01:59  

mouseClicked() method will be called in EventDispatcherThread, I am not sure what will be the impact of adding a sleep in EventDispatcherThread.

Try to add the cursor change in the following method

DBTableEventListener.onSortColumn(int column, boolean ascending) . This method will be called when user click the column header.

converge
Corporal

Gender: Unspecified
Location:
Registered: Apr 2004
Status: Offline
Posts: 28

Click here to see the profile for converge Send email to converge Send private message to converge Find more posts by converge Edit or delete this message Reply w/Quote
Posted Wednesday, October 22, 2008 @ 10:13:44  

Actually, I'm not supposed to use the Thread.sleep() call in my code. I only put it there to suspend the program long enough to see if the cursor changes or not. The real code should be:

Code:

dbtResults.getTableHeader().addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
dbtResults.sortByColumn(2, true);
setCursor(Cursor.getDefaultCursor());
}

public void mouseReleased(MouseEvent evt) {}
});

Basically, I want a "wait" cursor for when the table is sorting, and then to revert to the default cursor when it's done.

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Wednesday, October 22, 2008 @ 14:28:10  

Is the mouseclicked method getting invoked when you click the header?

Is it possible the sorting is fast, that the cursor is quickly switched back to default?

converge
Corporal

Gender: Unspecified
Location:
Registered: Apr 2004
Status: Offline
Posts: 28

Click here to see the profile for converge Send email to converge Send private message to converge Find more posts by converge Edit or delete this message Reply w/Quote
Posted Wednesday, October 22, 2008 @ 14:33:41  

Yes, the event is being called but the cursor is not changing. I'm sorting on ~200,000 rows so it actually takes around 3-4 seconds to perform. A client was complaining that they didn't know what was happening when they clicked the header because there was no cursor indication.
Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Monday, October 27, 2008 @ 08:43:03  

Instead of calling dbtable.setCursor, you can get the Jtable used by Quicktable and try to set the cursor.
dbtable.getTable().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios