equal
deleted
inserted
replaced
54 import javax.swing.plaf.OptionPaneUI; |
54 import javax.swing.plaf.OptionPaneUI; |
55 import javax.swing.event.InternalFrameEvent; |
55 import javax.swing.event.InternalFrameEvent; |
56 import javax.swing.event.InternalFrameAdapter; |
56 import javax.swing.event.InternalFrameAdapter; |
57 import javax.accessibility.*; |
57 import javax.accessibility.*; |
58 import static javax.swing.ClientPropertyKey.PopupFactory_FORCE_HEAVYWEIGHT_POPUP; |
58 import static javax.swing.ClientPropertyKey.PopupFactory_FORCE_HEAVYWEIGHT_POPUP; |
|
59 import sun.awt.AWTAccessor; |
59 |
60 |
60 /** |
61 /** |
61 * <code>JOptionPane</code> makes it easy to pop up a standard dialog box that |
62 * <code>JOptionPane</code> makes it easy to pop up a standard dialog box that |
62 * prompts users for a value or informs them of something. |
63 * prompts users for a value or informs them of something. |
63 * For information about using <code>JOptionPane</code>, see |
64 * For information about using <code>JOptionPane</code>, see |
1304 } |
1305 } |
1305 parent = parent.getParent(); |
1306 parent = parent.getParent(); |
1306 } |
1307 } |
1307 } |
1308 } |
1308 |
1309 |
1309 // Use reflection to get Container.startLWModal. |
1310 AWTAccessor.getContainerAccessor().startLWModal(dialog); |
1310 try { |
|
1311 Method method = AccessController.doPrivileged(new ModalPrivilegedAction( |
|
1312 Container.class, "startLWModal")); |
|
1313 if (method != null) { |
|
1314 method.invoke(dialog, (Object[])null); |
|
1315 } |
|
1316 } catch (IllegalAccessException ex) { |
|
1317 } catch (IllegalArgumentException ex) { |
|
1318 } catch (InvocationTargetException ex) { |
|
1319 } |
|
1320 |
1311 |
1321 if (parentComponent instanceof JInternalFrame) { |
1312 if (parentComponent instanceof JInternalFrame) { |
1322 try { |
1313 try { |
1323 ((JInternalFrame)parentComponent).setSelected(true); |
1314 ((JInternalFrame)parentComponent).setSelected(true); |
1324 } catch (java.beans.PropertyVetoException e) { |
1315 } catch (java.beans.PropertyVetoException e) { |
1449 } |
1440 } |
1450 parent = parent.getParent(); |
1441 parent = parent.getParent(); |
1451 } |
1442 } |
1452 } |
1443 } |
1453 |
1444 |
1454 // Use reflection to get Container.startLWModal. |
1445 AWTAccessor.getContainerAccessor().startLWModal(dialog); |
1455 try { |
|
1456 Method method = AccessController.doPrivileged(new ModalPrivilegedAction( |
|
1457 Container.class, "startLWModal")); |
|
1458 if (method != null) { |
|
1459 method.invoke(dialog, (Object[])null); |
|
1460 } |
|
1461 } catch (IllegalAccessException ex) { |
|
1462 } catch (IllegalArgumentException ex) { |
|
1463 } catch (InvocationTargetException ex) { |
|
1464 } |
|
1465 |
1446 |
1466 if (parentComponent instanceof JInternalFrame) { |
1447 if (parentComponent instanceof JInternalFrame) { |
1467 try { |
1448 try { |
1468 ((JInternalFrame)parentComponent).setSelected(true); |
1449 ((JInternalFrame)parentComponent).setSelected(true); |
1469 } catch (java.beans.PropertyVetoException e) { |
1450 } catch (java.beans.PropertyVetoException e) { |
1533 // if the user closed the iframe without selecting a button |
1514 // if the user closed the iframe without selecting a button |
1534 // (newValue = null in that case). Otherwise, close the dialog. |
1515 // (newValue = null in that case). Otherwise, close the dialog. |
1535 if (iFrame.isVisible() && |
1516 if (iFrame.isVisible() && |
1536 event.getSource() == JOptionPane.this && |
1517 event.getSource() == JOptionPane.this && |
1537 event.getPropertyName().equals(VALUE_PROPERTY)) { |
1518 event.getPropertyName().equals(VALUE_PROPERTY)) { |
1538 // Use reflection to get Container.stopLWModal(). |
1519 AWTAccessor.getContainerAccessor().stopLWModal(iFrame); |
1539 try { |
|
1540 Method method = AccessController.doPrivileged( |
|
1541 new ModalPrivilegedAction( |
|
1542 Container.class, "stopLWModal")); |
|
1543 if (method != null) { |
|
1544 method.invoke(iFrame, (Object[])null); |
|
1545 } |
|
1546 } catch (IllegalAccessException ex) { |
|
1547 } catch (IllegalArgumentException ex) { |
|
1548 } catch (InvocationTargetException ex) { |
|
1549 } |
|
1550 |
1520 |
1551 try { |
1521 try { |
1552 iFrame.setClosed(true); |
1522 iFrame.setClosed(true); |
1553 } |
1523 } |
1554 catch (java.beans.PropertyVetoException e) { |
1524 catch (java.beans.PropertyVetoException e) { |
2510 ",messageType=" + messageTypeString + |
2480 ",messageType=" + messageTypeString + |
2511 ",optionType=" + optionTypeString + |
2481 ",optionType=" + optionTypeString + |
2512 ",wantsInput=" + wantsInputString; |
2482 ",wantsInput=" + wantsInputString; |
2513 } |
2483 } |
2514 |
2484 |
2515 /** |
|
2516 * Retrieves a method from the provided class and makes it accessible. |
|
2517 */ |
|
2518 private static class ModalPrivilegedAction implements PrivilegedAction<Method> { |
|
2519 private Class<?> clazz; |
|
2520 private String methodName; |
|
2521 |
|
2522 public ModalPrivilegedAction(Class<?> clazz, String methodName) { |
|
2523 this.clazz = clazz; |
|
2524 this.methodName = methodName; |
|
2525 } |
|
2526 |
|
2527 public Method run() { |
|
2528 Method method = null; |
|
2529 try { |
|
2530 method = clazz.getDeclaredMethod(methodName, (Class[])null); |
|
2531 } catch (NoSuchMethodException ex) { |
|
2532 } |
|
2533 if (method != null) { |
|
2534 method.setAccessible(true); |
|
2535 } |
|
2536 return method; |
|
2537 } |
|
2538 } |
|
2539 |
|
2540 |
|
2541 |
|
2542 /////////////////// |
2485 /////////////////// |
2543 // Accessibility support |
2486 // Accessibility support |
2544 /////////////////// |
2487 /////////////////// |
2545 |
2488 |
2546 /** |
2489 /** |