-
Bug
-
Resolution: Fixed
-
P2
-
1.3.0_03, 1.3.1, 1.4.0
-
beta2
-
x86
-
linux
-
Verified
I can reproduce the bug on Redhat 7.1 and 6.1 using JRE 1.3.1, 1.3.0_03.
Didn't try RH 6.2 and other JREs.
The following are two small programs:
closewin is the main roboot program I used for automation.
=======================================================================
/* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
* ident %Z%%M% %I% %E%
* This code is provided "AS IS", without any warranty of any kind.
* Sun is under no obligation to provide maintenance or support for
* this code or provide future updates thereto.
* SUN DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF NON-
* INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
* OR ANY WARRANTIES ARISING FROM A COURSE OF DEALING, USAGE OR TRADE
* PRACTICE.
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.Robot.*;
import java.util.Vector;
public class closewin {
Robot rob;
int elapse = 20;
int [] keySequence = new int[10];
int totalKeys = 0;
public static void main(String [] args) {
closewin c = new closewin();
c.run(args);
}
/**
* Arguments:
* 1. None: Wait default 20 seconds and press/release enter key
* 2. [Time in seconds] [key sequence]
* e.g.
* 20
* 20 ALT S
* I am limiting the key press sequece to 10. It will be rare if
* you want to press more than 4 keys all together!
*/
public void run (String [] args) {
if ( args.length > 0 ) {
elapse = Integer.parseInt(args[0]);
}
if (args.length > 1) {
processKeySequence(args);
totalKeys = args.length - 1;
} else {
keySequence[0] = KeyEvent.VK_ENTER;
totalKeys = 1;
}
try {
rob = new Robot();
} catch (Exception e) {
System.out.println("Error in loading Robot!" + e.toString());
System.exit(-1);
}
try {
for(int i = elapse; i > 0; i--) {
// System.out.println("Time to close window in " + i + " seconds");
Thread.sleep(1000);
}
} catch (InterruptedException e) {}
for (int i = 0; i < totalKeys; i++) {
System.out.println("Pressing key " + keySequence[i]);
rob.keyPress(keySequence[i]);
}
// for (int i = totalKeys - 1; i >= 0; i--) {
for (int i = 0; i < totalKeys; i++) {
System.out.println("Releasing key " + keySequence[i]);
rob.keyRelease(keySequence[i]);
}
System.exit(0);
}
private void processKeySequence(String [] args) {
// The args[0] is second number
for (int i = 0; i < args.length - 1; i++) {
// Not implemented for all keys. For JWS test only here.
if (args[i+1].equals("ALT")) {
keySequence[i] = KeyEvent.VK_ALT;
} else if (args[i+1].equals("S")) {
keySequence[i] = KeyEvent.VK_S;
} else {
keySequence[i] = KeyEvent.VK_ENTER;
}
}
}
}
RobotBug is the small program used to demonstrate the problem. [Notice that there is no invocation of java.awt.Robot in this test!!!]
======================================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class RobotBug {
public static void main(String [] args) {
RobotBug r = new RobotBug();
}
RobotBug () {
JFrame f = new JFrame ();
Container c = f.getContentPane();
JButton b = new JButton("Alt+S for activation");
b.setMnemonic(KeyEvent.VK_S);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
);
c.add(b);
f.pack();
f.show();
}
}
The steps to run them is:
1. Run command:
java closewin 20 ALT S &
(ALT+S key will be pressed after 20 seconds.)
2. Run command:
java RobotBug
After a while, the RobotBug program will exit since Alt+S key is pressed.
(The RobotBug program has the focus.)
The above two program works on Solaris, Windows, but not on Linux.
Note the commented line in closewin.java:
// for (int i = totalKeys - 1; i >= 0; i--) {
I tried both release sequences, i.e. release last pressed key first, or
release first pressed key first, none of them worked.
nathan.wang@Eng 2001-07-10
Didn't try RH 6.2 and other JREs.
The following are two small programs:
closewin is the main roboot program I used for automation.
=======================================================================
/* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
* ident %Z%%M% %I% %E%
* This code is provided "AS IS", without any warranty of any kind.
* Sun is under no obligation to provide maintenance or support for
* this code or provide future updates thereto.
* SUN DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF NON-
* INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
* OR ANY WARRANTIES ARISING FROM A COURSE OF DEALING, USAGE OR TRADE
* PRACTICE.
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.Robot.*;
import java.util.Vector;
public class closewin {
Robot rob;
int elapse = 20;
int [] keySequence = new int[10];
int totalKeys = 0;
public static void main(String [] args) {
closewin c = new closewin();
c.run(args);
}
/**
* Arguments:
* 1. None: Wait default 20 seconds and press/release enter key
* 2. [Time in seconds] [key sequence]
* e.g.
* 20
* 20 ALT S
* I am limiting the key press sequece to 10. It will be rare if
* you want to press more than 4 keys all together!
*/
public void run (String [] args) {
if ( args.length > 0 ) {
elapse = Integer.parseInt(args[0]);
}
if (args.length > 1) {
processKeySequence(args);
totalKeys = args.length - 1;
} else {
keySequence[0] = KeyEvent.VK_ENTER;
totalKeys = 1;
}
try {
rob = new Robot();
} catch (Exception e) {
System.out.println("Error in loading Robot!" + e.toString());
System.exit(-1);
}
try {
for(int i = elapse; i > 0; i--) {
// System.out.println("Time to close window in " + i + " seconds");
Thread.sleep(1000);
}
} catch (InterruptedException e) {}
for (int i = 0; i < totalKeys; i++) {
System.out.println("Pressing key " + keySequence[i]);
rob.keyPress(keySequence[i]);
}
// for (int i = totalKeys - 1; i >= 0; i--) {
for (int i = 0; i < totalKeys; i++) {
System.out.println("Releasing key " + keySequence[i]);
rob.keyRelease(keySequence[i]);
}
System.exit(0);
}
private void processKeySequence(String [] args) {
// The args[0] is second number
for (int i = 0; i < args.length - 1; i++) {
// Not implemented for all keys. For JWS test only here.
if (args[i+1].equals("ALT")) {
keySequence[i] = KeyEvent.VK_ALT;
} else if (args[i+1].equals("S")) {
keySequence[i] = KeyEvent.VK_S;
} else {
keySequence[i] = KeyEvent.VK_ENTER;
}
}
}
}
RobotBug is the small program used to demonstrate the problem. [Notice that there is no invocation of java.awt.Robot in this test!!!]
======================================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class RobotBug {
public static void main(String [] args) {
RobotBug r = new RobotBug();
}
RobotBug () {
JFrame f = new JFrame ();
Container c = f.getContentPane();
JButton b = new JButton("Alt+S for activation");
b.setMnemonic(KeyEvent.VK_S);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
);
c.add(b);
f.pack();
f.show();
}
}
The steps to run them is:
1. Run command:
java closewin 20 ALT S &
(ALT+S key will be pressed after 20 seconds.)
2. Run command:
java RobotBug
After a while, the RobotBug program will exit since Alt+S key is pressed.
(The RobotBug program has the focus.)
The above two program works on Solaris, Windows, but not on Linux.
Note the commented line in closewin.java:
// for (int i = totalKeys - 1; i >= 0; i--) {
I tried both release sequences, i.e. release last pressed key first, or
release first pressed key first, none of them worked.
nathan.wang@Eng 2001-07-10