8208125: Cannot input text into JOptionPane Text Input Dialog
Reviewed-by: prr, psadhukhan
This commit is contained in:
parent
e146d6cdce
commit
7a9b62f2d4
@ -378,7 +378,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
|
|
||||||
// Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
|
// 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);
|
styleBits = SET(styleBits, RESIZABLE, resizable);
|
||||||
if (!resizable) {
|
if (!resizable) {
|
||||||
styleBits = SET(styleBits, ZOOMABLE, false);
|
styleBits = SET(styleBits, ZOOMABLE, false);
|
||||||
@ -482,16 +482,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
return styleBits;
|
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:]
|
// this is the counter-point to -[CWindow _nativeSetStyleBit:]
|
||||||
private void setStyleBits(final int mask, final boolean value) {
|
private void setStyleBits(final int mask, final boolean value) {
|
||||||
execute(ptr -> nativeSetNSWindowStyleBits(ptr, mask, value ? mask : 0));
|
execute(ptr -> nativeSetNSWindowStyleBits(ptr, mask, value ? mask : 0));
|
||||||
@ -686,9 +676,10 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
// Manage the extended state when showing
|
// Manage the extended state when showing
|
||||||
if (visible) {
|
if (visible) {
|
||||||
/* Frame or Dialog should be set property WINDOW_FULLSCREENABLE to true if the
|
/* 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) {
|
if (resizable) {
|
||||||
setCanFullscreen(true);
|
setCanFullscreen(true);
|
||||||
}
|
}
|
||||||
@ -823,10 +814,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setResizable(final boolean resizable) {
|
public void setResizable(final boolean resizable) {
|
||||||
final boolean windowResizable = resizable && isNativelyFocusableWindow();
|
setCanFullscreen(resizable);
|
||||||
setCanFullscreen(windowResizable);
|
setStyleBits(RESIZABLE, resizable);
|
||||||
setStyleBits(RESIZABLE, windowResizable);
|
setStyleBits(ZOOMABLE, resizable);
|
||||||
setStyleBits(ZOOMABLE, windowResizable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -868,8 +858,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateFocusableWindowState() {
|
public void updateFocusableWindowState() {
|
||||||
setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN | RESIZABLE,
|
final boolean isFocusable = isNativelyFocusableWindow();
|
||||||
(isNativelyFocusableWindow() && isTargetResizable()));
|
setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -147,7 +147,7 @@ java/awt/event/KeyEvent/CorrectTime/CorrectTime.java 6626492 generic-all
|
|||||||
java/awt/EventQueue/6980209/bug6980209.java 8198615 macosx-all
|
java/awt/EventQueue/6980209/bug6980209.java 8198615 macosx-all
|
||||||
java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java 8198237 macosx-all
|
java/awt/Frame/ExceptionOnSetExtendedStateTest/ExceptionOnSetExtendedStateTest.java 8198237 macosx-all
|
||||||
java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java 8144030 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/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java 7080150 macosx-all
|
||||||
java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java 8168646 generic-all
|
java/awt/event/InputEvent/EventWhenTest/EventWhenTest.java 8168646 generic-all
|
||||||
java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogButtonTest/EnqueueWithDialogButtonTest.java 8198623 macosx-all
|
java/awt/KeyboardFocusmanager/TypeAhead/EnqueueWithDialogButtonTest/EnqueueWithDialogButtonTest.java 8198623 macosx-all
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
@test
|
@test
|
||||||
@key headful
|
@key headful
|
||||||
@bug 4980161 7158623 8204860
|
@bug 4980161 7158623 8204860 8208125
|
||||||
@summary Setting focusable window state to false makes the maximized frame resizable
|
@summary Setting focusable window state to false makes the maximized frame resizable
|
||||||
@compile UnfocusableMaximizedFrameResizablity.java
|
@compile UnfocusableMaximizedFrameResizablity.java
|
||||||
@run main UnfocusableMaximizedFrameResizablity
|
@run main UnfocusableMaximizedFrameResizablity
|
||||||
@ -36,13 +36,10 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.AWTException;
|
import java.awt.AWTException;
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.Robot;
|
import java.awt.Robot;
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
public class UnfocusableMaximizedFrameResizablity {
|
public class UnfocusableMaximizedFrameResizablity {
|
||||||
|
|
||||||
private static Frame frame;
|
private static Frame frame;
|
||||||
private static JFrame jframe;
|
|
||||||
private static Robot robot;
|
private static Robot robot;
|
||||||
private static boolean isProgInterruption = false;
|
private static boolean isProgInterruption = false;
|
||||||
private static Thread mainThread = null;
|
private static Thread mainThread = null;
|
||||||
@ -55,65 +52,13 @@ public class UnfocusableMaximizedFrameResizablity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Case 1: Setting frame resizable to true followed by focusable to false
|
frame = new Frame("Unfocusable frame");
|
||||||
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.setMaximizedBounds(new Rectangle(0, 0, 300, 300));
|
frame.setMaximizedBounds(new Rectangle(0, 0, 300, 300));
|
||||||
frame.setSize(200, 200);
|
frame.setSize(200, 200);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||||
|
frame.setFocusableWindowState(false);
|
||||||
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void tryToResizeFrame(Frame frame) {
|
|
||||||
try {
|
try {
|
||||||
robot = new Robot();
|
robot = new Robot();
|
||||||
} catch (AWTException e) {
|
} catch (AWTException e) {
|
||||||
@ -144,11 +89,11 @@ public class UnfocusableMaximizedFrameResizablity {
|
|||||||
cleanup();
|
cleanup();
|
||||||
throw new RuntimeException("The maximized unfocusable frame can be resized.");
|
throw new RuntimeException("The maximized unfocusable frame can be resized.");
|
||||||
}
|
}
|
||||||
|
cleanup();
|
||||||
frame.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cleanup() {
|
private static void cleanup() {
|
||||||
|
frame.dispose();
|
||||||
isProgInterruption = true;
|
isProgInterruption = true;
|
||||||
mainThread.interrupt();
|
mainThread.interrupt();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user