-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_nt
Name: bsC130419 Date: 06/28/2001
C:\tmp>\jdk1.3.1\bin\java -version
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
use "setCursor" API to set up a busy cursor in a modal dialog.
When "Apply" button clicked, use "setCursor" to set up a "WAIT"
cursor, then execute a long task, after the task is finished, use
"setCursor" to set back to "DEFAULT" cursor.
In Solaris 2.7(x86), both jdk 1.3.1 and jdk 1.2.2 run well.
but in Windows NT 4.0, jdk1.2.2 is OK, jdk 1.3.1 is not OK.
After the cursor becomes an hourglass, use the mouse to move it out of
the dialog, then move it back, the "hourglass" never comes back.
Please compile and run the sample code.
1. javac test_dialog.java
2. javac test.java
3. java test
4. click OK button
5. click Apply button, cursor becomes hourglass
6. move cursor out of the dialog, then move cursor back,
you see cursor keeps "arrow" shape, not hourglass
----test_dialog.java (start)--------
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class test_dialog extends JDialog
{
JPanel base_panel = new JPanel();
BorderLayout borderLayout1 = new BorderLayout();
JPanel up_JPanel = new JPanel();
BorderLayout borderLayout2 = new BorderLayout();
JPanel down_JPanel = new JPanel();
JButton jButtonApply = new JButton();
JButton jButtonOK = new JButton();
JButton jButtonCancel = new JButton();
public test_dialog(Frame frame, String title, boolean modal)
{
super(frame, title+" dialog cursor", modal);
try
{
jbInit();
//pack();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public test_dialog()
{
this(null, "", false);
}
void jbInit() throws Exception
{
base_panel.setLayout(borderLayout1);
jButtonApply.setMinimumSize(new Dimension(83, 27));
jButtonApply.setMnemonic('A');
jButtonApply.setText("Apply");
jButtonApply.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
jButtonApply_actionPerformed(e);
}
});
jButtonOK.setMinimumSize(new Dimension(83, 27));
jButtonOK.setMnemonic('O');
jButtonOK.setText("OK");
jButtonOK.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//jButtonOK_actionPerformed(e);
}
});
jButtonCancel.setMinimumSize(new Dimension(83, 27));
jButtonCancel.setMnemonic('C');
jButtonCancel.setText("Cancel");
jButtonCancel.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//jButtonCancel_actionPerformed(e);
}
});
base_panel.setPreferredSize(new Dimension(420, 575));
down_JPanel.setLayout(flowLayout1);
flowLayout1.setAlignment(FlowLayout.RIGHT);
getContentPane().add(base_panel);
up_JPanel.setPreferredSize(new Dimension(386, 480));
base_panel.add(up_JPanel, BorderLayout.CENTER);
base_panel.add(down_JPanel, BorderLayout.SOUTH);
down_JPanel.add(jButtonOK, null);
down_JPanel.add(jButtonCancel, null);
down_JPanel.add(jButtonApply, null);
getRootPane().setDefaultButton(jButtonOK);
}
FlowLayout flowLayout1 = new FlowLayout();
void jButtonApply_actionPerformed(ActionEvent e)
{
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
/*
getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
getRootPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
base_panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
*/
try {
Thread.sleep(10000); //sleep for 10 seconds
} catch (InterruptedException e1) {
}
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
/*
getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
getRootPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
base_panel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
*/
}
}
----test_dialog.java (end) ---------
----test.java (start)-----------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test extends JFrame
{
public test()
{
JPanel aJPanel = new JPanel();
getContentPane().add(aJPanel);
JButton aJButton = new JButton("OK");
aJButton.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ok_action(e);
}
});
aJPanel.add(aJButton);
setVisible(true);
setSize(new Dimension(300,300));
SwingUtilities.updateComponentTreeUI(this);
}
void ok_action(ActionEvent e)
{
test_dialog atest_dialog = new test_dialog(this, "test", true);
atest_dialog.pack();
atest_dialog.setLocationRelativeTo(this);
//atest_dialog.setModal(true);
atest_dialog.setVisible(true);
}
public static void main(String[] args)
{
test atest = new test();
}
}
----test.java (end)-------------
(Review ID: 125361)
======================================================================
- duplicates
-
JDK-4372119 Disappearing of busy cursor on JDK 1.3
- Closed