Navigation Menu

Skip to content

Commit

Permalink
Backport c638618
Browse files Browse the repository at this point in the history
  • Loading branch information
RealCLanger committed Oct 15, 2021
1 parent fcb396f commit e4baa3e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Expand Up @@ -778,7 +778,6 @@ javax/swing/text/StyledEditorKit/4506788/bug4506788.java 8233562 macosx-all
javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java 233570 macosx-all
javax/swing/text/GlyphPainter2/6427244/bug6427244.java 8208566 macosx-all
javax/swing/ProgressMonitor/ProgressMonitorEscapeKeyPress.java 8233635 macosx-all
javax/swing/plaf/nimbus/TestNimbusOverride.java 8233559 macosx-all
javax/swing/JTree/4927934/bug4927934.java 8233550 macosx-all
javax/swing/JTree/4908142/bug4908142.java 8233550 macosx-all
javax/swing/JTree/4330357/bug4330357.java 8233550 macosx-all
Expand Down
53 changes: 28 additions & 25 deletions test/jdk/javax/swing/plaf/nimbus/TestNimbusOverride.java
Expand Up @@ -31,17 +31,14 @@
*/

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.Robot;
import java.awt.event.KeyEvent;

import javax.swing.AbstractAction;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
Expand All @@ -56,36 +53,41 @@ public class TestNimbusOverride extends JFrame
private static boolean passed = false;

public static void main(String [] args) throws Exception {
Robot robot = new Robot();
SwingUtilities.invokeAndWait(() -> {
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
throw new RuntimeException(e);
}
tf = new TestNimbusOverride();
tf.pack();
tf.setVisible(true);
});
robot.setAutoDelay(100);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
robot.waitForIdle();
SwingUtilities.invokeAndWait(() -> tf.dispose());
if (!passed) {
try {
Robot robot = new Robot();
SwingUtilities.invokeAndWait(() -> {
try {
UIManager.setLookAndFeel(
"javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
throw new RuntimeException(e);
}
tf = new TestNimbusOverride();
tf.pack();
tf.setVisible(true);
});
robot.setAutoDelay(100);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
robot.waitForIdle();
if (!passed) {
throw new RuntimeException(
"Setting Nimbus.Overrides property affects custom keymap installation");
"Setting Nimbus.Overrides property affects custom" +
" keymap installation");
}
} finally {
SwingUtilities.invokeAndWait(() -> tf.dispose());
}
}

public TestNimbusOverride()
{
setDefaultCloseOperation(DISPOSE_ON_CLOSE);

/*
* Create a frame containing a JEditorPane, and override the action for the space bar to show
* a dialog.
* Create a frame containing a JEditorPane, and override the action for
* the space bar to show a dialog.
*/
JEditorPane pp = new JEditorPane();
UIDefaults defaults = new UIDefaults();
Expand All @@ -102,7 +104,8 @@ public TestNimbusOverride()
Keymap origKeymap = pp.getKeymap();
Keymap km = JEditorPane.addKeymap("Test keymap", origKeymap);

km.addActionForKeyStroke(KeyStroke.getKeyStroke(' '), new AbstractAction("SHOW_SPACE") {
km.addActionForKeyStroke(KeyStroke.getKeyStroke(' '),
new AbstractAction("SHOW_SPACE") {
@Override
public void actionPerformed(ActionEvent e)
{
Expand Down

0 comments on commit e4baa3e

Please sign in to comment.