31
31
* @author Alexander Zuev
32
32
* @run main bug4966112
33
33
*/
34
- import javax .swing .*;
34
+ import javax .swing .JButton ;
35
+ import javax .swing .JComponent ;
36
+ import javax .swing .JFileChooser ;
37
+ import javax .swing .JFrame ;
38
+ import javax .swing .JPanel ;
39
+ import javax .swing .JPopupMenu ;
40
+ import javax .swing .JSpinner ;
41
+ import javax .swing .JSplitPane ;
42
+ import javax .swing .SwingUtilities ;
43
+ import javax .swing .UIManager ;
35
44
import javax .swing .event .PopupMenuListener ;
36
45
import javax .swing .event .PopupMenuEvent ;
37
- import java .awt .*;
38
- import java .awt .event .*;
46
+
47
+ import java .awt .BorderLayout ;
48
+ import java .awt .Dimension ;
49
+ import java .awt .Robot ;
50
+ import java .awt .Point ;
51
+ import java .awt .event .InputEvent ;
52
+ import java .awt .event .KeyEvent ;
53
+ import java .awt .event .MouseAdapter ;
54
+ import java .awt .event .MouseEvent ;
39
55
40
56
public class bug4966112 {
41
57
@@ -48,6 +64,7 @@ public class bug4966112 {
48
64
private static volatile JFileChooser filec ;
49
65
private static int buttonMask ;
50
66
private static Robot robot ;
67
+ private static boolean isAquaFileChooser ;
51
68
52
69
public static void main (String [] args ) throws Exception {
53
70
robot = new Robot ();
@@ -99,6 +116,11 @@ public static void main(String[] args) throws Exception {
99
116
createAndShowFileChooser ();
100
117
robot .waitForIdle ();
101
118
119
+ if ((UIManager .getLookAndFeel ().getID ()).equals ("Aqua" )) {
120
+ isAquaFileChooser = true ;
121
+ } else {
122
+ isAquaFileChooser = false ;
123
+ }
102
124
clickMouse (filec );
103
125
robot .waitForIdle ();
104
126
@@ -146,7 +168,11 @@ private static void setClickPoint(final JComponent c) throws Exception {
146
168
public void run () {
147
169
Point p = c .getLocationOnScreen ();
148
170
Dimension size = c .getSize ();
149
- result [0 ] = new Point (p .x + size .width / 2 , p .y + size .height / 2 );
171
+ if (isAquaFileChooser ) {
172
+ result [0 ] = new Point (p .x + size .width / 2 , p .y + 5 );
173
+ } else {
174
+ result [0 ] = new Point (p .x + size .width / 2 , p .y + size .height / 2 );
175
+ }
150
176
}
151
177
});
152
178
0 commit comments