8208125: Cannot input text into JOptionPane Text Input Dialog
Reviewed-by: prr, psadhukhan
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Aug 09 07:58:25 2018 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Aug 09 22:47:18 2018 +0530
@@ -378,7 +378,7 @@
// Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
{
- final boolean resizable = isTargetResizable() && isNativelyFocusableWindow();
+ final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
styleBits = SET(styleBits, RESIZABLE, resizable);
if (!resizable) {
styleBits = SET(styleBits, ZOOMABLE, false);
@@ -482,16 +482,6 @@
return styleBits;
}
- private boolean isTargetResizable() {
- if (target instanceof Frame) {
- return ((Frame)target).isResizable();
- } else if (target instanceof Dialog) {
- return ((Dialog)target).isResizable();
- }
-
- return false;
- }
-
// this is the counter-point to -[CWindow _nativeSetStyleBit:]
private void setStyleBits(final int mask, final boolean value) {
execute(ptr -> nativeSetNSWindowStyleBits(ptr, mask, value ? mask : 0));
@@ -686,9 +676,10 @@
// Manage the extended state when showing
if (visible) {
/* Frame or Dialog should be set property WINDOW_FULLSCREENABLE to true if the
- Frame or Dialog is resizable and focusable.
+ Frame or Dialog is resizable.
**/
- final boolean resizable = isTargetResizable() && isNativelyFocusableWindow();
+ final boolean resizable = (target instanceof Frame) ? ((Frame)target).isResizable() :
+ ((target instanceof Dialog) ? ((Dialog)target).isResizable() : false);
if (resizable) {
setCanFullscreen(true);
}
@@ -823,10 +814,9 @@
@Override
public void setResizable(final boolean resizable) {
- final boolean windowResizable = resizable && isNativelyFocusableWindow();
- setCanFullscreen(windowResizable);
- setStyleBits(RESIZABLE, windowResizable);
- setStyleBits(ZOOMABLE, windowResizable);
+ setCanFullscreen(resizable);
+ setStyleBits(RESIZABLE, resizable);
+ setStyleBits(ZOOMABLE, resizable);
}
@Override
@@ -868,8 +858,8 @@
@Override
public void updateFocusableWindowState() {
- setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN | RESIZABLE,
- (isNativelyFocusableWindow() && isTargetResizable()));
+ final boolean isFocusable = isNativelyFocusableWindow();
+ setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once
}
@Override
--- a/test/jdk/ProblemList.txt Thu Aug 09 07:58:25 2018 -0700
+++ b/test/jdk/ProblemList.txt Thu Aug 09 22:47:18 2018 +0530
@@ -147,7 +147,7 @@
java/awt/EventQueue/6980209/bug6980209.java 8198615 macosx-all
java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java 8198237 macosx-all
java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java 8144030 macosx-all
-java/awt/Frame/UnfocusableMaximizedFrameResizablity/UnfocusableMaximizedFrameResizablity.java 7158623 macosx-all
+java/awt/Frame/UnfocusableMaximizedFrameResizablity/UnfocusableMaximizedFrameResizablity.java 8208290 macosx-all
java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java 7080150 macosx-all
java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java 8168646 generic-all
java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogButtonTest/EnqueueWithDialogButtonTest.java 8198623 macosx-all
--- a/test/jdk/java/awt/Frame/UnfocusableMaximizedFrameResizablity/UnfocusableMaximizedFrameResizablity.java Thu Aug 09 07:58:25 2018 -0700
+++ b/test/jdk/java/awt/Frame/UnfocusableMaximizedFrameResizablity/UnfocusableMaximizedFrameResizablity.java Thu Aug 09 22:47:18 2018 +0530
@@ -24,7 +24,7 @@
/*
@test
@key headful
- @bug 4980161 7158623 8204860
+ @bug 4980161 7158623 8204860 8208125
@summary Setting focusable window state to false makes the maximized frame resizable
@compile UnfocusableMaximizedFrameResizablity.java
@run main UnfocusableMaximizedFrameResizablity
@@ -36,13 +36,10 @@
import java.awt.AWTException;
import java.awt.event.InputEvent;
import java.awt.Robot;
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
public class UnfocusableMaximizedFrameResizablity {
private static Frame frame;
- private static JFrame jframe;
private static Robot robot;
private static boolean isProgInterruption = false;
private static Thread mainThread = null;
@@ -55,65 +52,13 @@
return;
}
- //Case 1: Setting frame resizable to true followed by focusable to false
- frame = createFrame("Resizable Unfocusable frame");
- frame.setResizable(true);
- frame.setFocusableWindowState(false);
- tryToResizeFrame(frame);
-
- //Case 2: Setting frame focusable to false followed by resizable to true
- frame = createFrame("Unfocusable Resizable frame");
- frame.setFocusableWindowState(false);
- frame.setResizable(true);
- tryToResizeFrame(frame);
-
- //Case 3: Testing JFrame fullscreen behaviour only on Mac OS
- if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
- SwingUtilities.invokeAndWait(new Runnable() {
-
- Override
- public void run() {
- jframe = createJFrame("Unfocusable Resizable JFrame");
- jframe.setFocusableWindowState(false);
- jframe.setResizable(true);
- Object prop1 = jframe.getRootPane().getClientProperty("apple.awt.fullscreenable");
- jframe.setVisible(false);
- jframe.setVisible(true);
- Object prop2 = jframe.getRootPane().getClientProperty("apple.awt.fullscreenable");
-
- if((prop1 != null && prop2 != null) && (!prop1.equals(prop2))) {
- jframe.dispose();
- cleanup();
- throw new RuntimeException("Non-focusable resizable JFrame is fullscreenable!!");
- }
- }
- });
- }
-
- cleanup();
- }
-
- private static JFrame createJFrame(String title) {
- JFrame jframe = new JFrame(title);
- jframe.setMaximizedBounds(new Rectangle(0, 0, 300, 300));
- jframe.setSize(200, 200);
- jframe.setVisible(true);
- jframe.setExtendedState(Frame.MAXIMIZED_BOTH);
-
- return jframe;
- }
-
- private static Frame createFrame(String title) {
- Frame frame = new Frame(title);
+ frame = new Frame("Unfocusable frame");
frame.setMaximizedBounds(new Rectangle(0, 0, 300, 300));
frame.setSize(200, 200);
frame.setVisible(true);
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
+ frame.setFocusableWindowState(false);
- return frame;
- }
-
- private static void tryToResizeFrame(Frame frame) {
try {
robot = new Robot();
} catch (AWTException e) {
@@ -144,11 +89,11 @@
cleanup();
throw new RuntimeException("The maximized unfocusable frame can be resized.");
}
-
- frame.dispose();
+ cleanup();
}
private static void cleanup() {
+ frame.dispose();
isProgInterruption = true;
mainThread.interrupt();
}