Wait Cursor stuck in Table Header, bug??

Q

quelcher

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
 
D

Daniel Pitts

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
Could you provide an SSCCE?
<http://mindprod.com/jgloss/sscce.html>
 
Q

quelcher

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);
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top