-
Bug
-
Resolution: Fixed
-
P4
-
8, 8u25, 9
-
b127
-
x86_64
-
linux
FULL PRODUCT VERSION :
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux fox 2.6.32-5-amd64 #1 SMP Tue May 13 16:34:35 UTC 2014 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The isCanceled() method of ProgressMonitor returns false if the use presses Esc while the ProgressMonitor's dialog has keyboard focus. The dialog closes, but isCanceled() continues to return false.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Display a ProgressMonitor dialog. Before it reaches its maximum progress value, press Esc to close it (as opposed to activating the Cancel button or closing the dialog via the window manager). Observe the value returned by the ProgressMonitor's isCanceled() method.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pressing Esc should perform exactly the same action as activating the dialog's Cancel button. The isCanceled() method of the ProgressMonitor should return true.
ACTUAL -
When the ProgressMonitor's dialog is closed by pressing Esc, the isCanceled() method continues to return false. Closing the ProgressMonitor's dialog by any other means correctly causes isCanceled() to return true.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.ProgressMonitor;
public class ProgressMonitorTest {
static ProgressMonitor monitor;
static int p;
public static void main(String[] args)
throws InterruptedException,
ReflectiveOperationException {
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Test");
frame.setSize(300, 300);
frame.setLocationByPlatform(true);
frame.setVisible(true);
monitor = new ProgressMonitor(frame, "Progress", null, 0, 100);
}
});
for (p = 10; p <= 100; p += 10) {
Thread.sleep(1000);
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
if (!monitor.isCanceled()) {
monitor.setProgress(p);
}
}
});
}
EventQueue.invokeAndWait(
() -> System.out.println("Canceled=" + monitor.isCanceled()));
System.exit(0);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Create your own dialog (possibly a JOptionPane) and put a JProgressBar in it.
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux fox 2.6.32-5-amd64 #1 SMP Tue May 13 16:34:35 UTC 2014 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
The isCanceled() method of ProgressMonitor returns false if the use presses Esc while the ProgressMonitor's dialog has keyboard focus. The dialog closes, but isCanceled() continues to return false.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Display a ProgressMonitor dialog. Before it reaches its maximum progress value, press Esc to close it (as opposed to activating the Cancel button or closing the dialog via the window manager). Observe the value returned by the ProgressMonitor's isCanceled() method.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Pressing Esc should perform exactly the same action as activating the dialog's Cancel button. The isCanceled() method of the ProgressMonitor should return true.
ACTUAL -
When the ProgressMonitor's dialog is closed by pressing Esc, the isCanceled() method continues to return false. Closing the ProgressMonitor's dialog by any other means correctly causes isCanceled() to return true.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.ProgressMonitor;
public class ProgressMonitorTest {
static ProgressMonitor monitor;
static int p;
public static void main(String[] args)
throws InterruptedException,
ReflectiveOperationException {
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Test");
frame.setSize(300, 300);
frame.setLocationByPlatform(true);
frame.setVisible(true);
monitor = new ProgressMonitor(frame, "Progress", null, 0, 100);
}
});
for (p = 10; p <= 100; p += 10) {
Thread.sleep(1000);
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
if (!monitor.isCanceled()) {
monitor.setProgress(p);
}
}
});
}
EventQueue.invokeAndWait(
() -> System.out.println("Canceled=" + monitor.isCanceled()));
System.exit(0);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Create your own dialog (possibly a JOptionPane) and put a JProgressBar in it.
- duplicates
-
JDK-6357974 ProgressMonitor - ESC key does not set cancelled state
-
- Closed
-
There are no Sub-Tasks for this issue.