test/javax/swing/plaf/windows/WindowsRootPaneUI/WrongAltProcessing/WrongAltProcessing.java
Print this page
*** 20,30 ****
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
! @bug 8001633
@summary Wrong alt processing during switching between windows
@author mikhail.cherkasov@oracle.com
@run main WrongAltProcessing
*/
--- 20,30 ----
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
! @bug 8001633 8028271
@summary Wrong alt processing during switching between windows
@author mikhail.cherkasov@oracle.com
@run main WrongAltProcessing
*/
*** 42,62 ****
private static JFrame secondFrame;
private static JTextField mainFrameTf1;
private static JTextField mainFrameTf2;
private static JTextField secondFrameTf;
! public static void main(String[] args) throws AWTException {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
return;// miss unsupported platforms.
}
createWindows();
initRobot();
runScript();
verify();
}
private static void verify() {
Component c = DefaultKeyboardFocusManager
.getCurrentKeyboardFocusManager().getFocusOwner();
if (!(c == mainFrameTf2)) {
--- 42,73 ----
private static JFrame secondFrame;
private static JTextField mainFrameTf1;
private static JTextField mainFrameTf2;
private static JTextField secondFrameTf;
! public static void main(String[] args) throws Exception {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e) {
return;// miss unsupported platforms.
}
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
createWindows();
+ }
+ });
+ sync();
initRobot();
runScript();
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
verify();
}
+ });
+ }
private static void verify() {
Component c = DefaultKeyboardFocusManager
.getCurrentKeyboardFocusManager().getFocusOwner();
if (!(c == mainFrameTf2)) {
*** 74,84 ****
robot.setAutoDelay(100);
}
private static void clickWindowsTitle(JFrame frame) {
Point point = frame.getLocationOnScreen();
! robot.mouseMove(point.x + (frame.getWidth() / 2), point.y + 5);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void runScript() {
--- 85,95 ----
robot.setAutoDelay(100);
}
private static void clickWindowsTitle(JFrame frame) {
Point point = frame.getLocationOnScreen();
! robot.mouseMove(point.x + (frame.getWidth() / 2), point.y + frame.getInsets().top / 2);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
public static void runScript() {
*** 110,119 ****
--- 121,131 ----
}
public static void createWindows() {
firstFrame = new JFrame("Frame");
firstFrame.setLayout(new FlowLayout());
+ firstFrame.setPreferredSize(new Dimension(600,100));
JMenuBar bar = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem item = new JMenuItem("Save");
*** 144,169 ****
firstFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
firstFrame.pack();
secondFrame = new JFrame("Frame 2");
secondFrame.setLocation(0, 150);
secondFrameTf = new JTextField(20);
secondFrame.add(secondFrameTf);
secondFrame.pack();
! SwingUtilities.invokeLater(new Runnable() {
! @Override
! public void run() {
secondFrame.setVisible(true);
! }
! });
! SwingUtilities.invokeLater(new Runnable() {
! @Override
! public void run() {
firstFrame.setVisible(true);
- }
- });
mainFrameTf1.requestFocus();
- sync();
}
}
--- 156,173 ----
firstFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
firstFrame.pack();
secondFrame = new JFrame("Frame 2");
+ secondFrame.setPreferredSize(new Dimension(600,100));
secondFrame.setLocation(0, 150);
secondFrameTf = new JTextField(20);
secondFrame.add(secondFrameTf);
secondFrame.pack();
!
secondFrame.setVisible(true);
!
firstFrame.setVisible(true);
mainFrameTf1.requestFocus();
}
}