278 }
279 }
280
281 // Fix for 6446952.
282 // In the process of showing the dialog we have to catch peer.show() call
283 // so that to trigger key events just before it gets invoked.
284 // We base on the fact that a modal dialog sets type-ahead markers
285 // before it calls 'show' on the peer.
286 // Posting the key events before dialog.setVisible(true) would be actually not
287 // good because it would be Ok to dispatch them to the current focus owner,
288 // not to the dialog.
289 class TestDialog extends Dialog {
290 ComponentPeer origDialogPeer;
291 ComponentPeer proxyInstPeer;
292 Semaphore trigger;
293
294 TestDialog(Frame owner, String title, boolean modal, Semaphore trigger) {
295 super(owner, title, modal);
296 this.trigger = trigger;
297 }
298 public ComponentPeer getPeer() {
299 ComponentPeer ret = super.getPeer();
300 if (ret == proxyInstPeer) {
301 return origDialogPeer;
302 } else {
303 return ret;
304 }
305 }
306
307 public void addNotify() {
308 super.addNotify();
309 replacePeer();
310 }
311
312 void replacePeer() {
313 origDialogPeer = getPeer();
314
315 InvocationHandler handler = new InvocationHandler() {
316 public Object invoke(Object proxy, Method method, Object[] args) {
317 if (method.getName() == "show") {
318 trigger.raise();
319 }
320
321 Object ret = null;
322 try {
323 ret = method.invoke(origDialogPeer, args);
324 } catch (IllegalAccessException iae) {
325 throw new Error("Test error.", iae);
326 } catch (InvocationTargetException ita) {
327 throw new Error("Test error.", ita);
328 }
329 return ret;
330 }
331 };
332
333 proxyInstPeer = (DialogPeer)Proxy.newProxyInstance(
334 DialogPeer.class.getClassLoader(), new Class[] {DialogPeer.class}, handler);
335
336 try {
337 Util.getField(Component.class, "peer").set(d, proxyInstPeer);
338 } catch (IllegalAccessException iae) {
339 throw new Error("Test error.", iae);
340 }
341 }
342 }
343 }// class TestDialogTypeAhead
344
345
346 /****************************************************
347 Standard Test Machinery
348 DO NOT modify anything below -- it's a standard
349 chunk of code whose purpose is to make user
350 interaction uniform, and thereby make it simpler
351 to read and understand someone else's test.
352 ****************************************************/
353
354 /**
355 This is part of the standard test machinery.
356 It creates a dialog (with the instructions), and is the interface
357 for sending text messages to the user.
358 To print the instructions, send an array of strings to Sysout.createDialog
359 WithInstructions method. Put one line of instructions per array entry.
360 To display a message for the tester to see, simply call Sysout.println
|
278 }
279 }
280
281 // Fix for 6446952.
282 // In the process of showing the dialog we have to catch peer.show() call
283 // so that to trigger key events just before it gets invoked.
284 // We base on the fact that a modal dialog sets type-ahead markers
285 // before it calls 'show' on the peer.
286 // Posting the key events before dialog.setVisible(true) would be actually not
287 // good because it would be Ok to dispatch them to the current focus owner,
288 // not to the dialog.
289 class TestDialog extends Dialog {
290 ComponentPeer origDialogPeer;
291 ComponentPeer proxyInstPeer;
292 Semaphore trigger;
293
294 TestDialog(Frame owner, String title, boolean modal, Semaphore trigger) {
295 super(owner, title, modal);
296 this.trigger = trigger;
297 }
298
299 public void addNotify() {
300 super.addNotify();
301 }
302 }
303 }// class TestDialogTypeAhead
304
305
306 /****************************************************
307 Standard Test Machinery
308 DO NOT modify anything below -- it's a standard
309 chunk of code whose purpose is to make user
310 interaction uniform, and thereby make it simpler
311 to read and understand someone else's test.
312 ****************************************************/
313
314 /**
315 This is part of the standard test machinery.
316 It creates a dialog (with the instructions), and is the interface
317 for sending text messages to the user.
318 To print the instructions, send an array of strings to Sysout.createDialog
319 WithInstructions method. Put one line of instructions per array entry.
320 To display a message for the tester to see, simply call Sysout.println
|