|
1 | 1 | Notes |
2 | 2 | ===== |
| 3 | +updated 10/26/19 -- adds information about File.createTempFile() |
3 | 4 | updated 8/16/19 -- minor typos and added summary paragraph |
4 | 5 | updated 7/19/19 -- clarification that AWT and Swing classes are supported directly |
5 | 6 | updated 5/13/19 -- Mandarin U+79D8 reserved character; Missing Math methods; int and long |
@@ -233,6 +234,12 @@ a2s components, which in turn subclass JComponents. So no changes in code are ne |
233 | 234 | successfully transpiled over 500 applets using this strategy. (Kind of surprising, actually, that |
234 | 235 | the original Java developers did not see that option. But we have a hindsight advantage here.) |
235 | 236 |
|
| 237 | +Temporary Files |
| 238 | +=============== |
| 239 | + |
| 240 | +SwingJS will maintain a pseudo-filesystem for files created with File.createTempFile(). This |
| 241 | +is useful in that closure of writing to the file does not generate a download to the user's |
| 242 | +machine (which typically requires user intervention). |
236 | 243 |
|
237 | 244 | UNIMPLEMENTED CLASSES BY DESIGN |
238 | 245 | =============================== |
@@ -459,6 +466,76 @@ It's a simple modification: |
459 | 466 | System.out.println("int value is " + value); |
460 | 467 | } |
461 | 468 |
|
| 469 | +javax.swing.JOptionPane dialogs |
| 470 | +------------------------------- |
| 471 | + |
| 472 | +For this action to work, the parentComponent must implement |
| 473 | +propertyChangeListener, and any call to JOptionPanel should allow for |
| 474 | +asynchronous response. |
| 475 | + |
| 476 | +In addition, for compatibility with the Java version, implementation should |
| 477 | +wrap the call to getConfirmDialog or getOptionDialog in a method call to |
| 478 | +handle the Java: |
| 479 | + |
| 480 | +onDialogReturn(JOptionPane.showConfirmDialog(parentFrame, |
| 481 | +messageOrMessagePanel, "title", JOptionPane.OK_CANCEL_OPTION)); |
| 482 | + |
| 483 | +Then parentFrame.propertyChange(event) should also call onDialogReturn. |
| 484 | + |
| 485 | +This will then work in both Java and JavaScript. |
| 486 | + |
| 487 | +Note that there is an int and an Object version of onDialogReturn(). |
| 488 | + |
| 489 | + |
| 490 | +In JavaScript: |
| 491 | + |
| 492 | +The initial return from JOptionPane.showConfirmDialog and showMessageDialog |
| 493 | +will be NaN, testable as an impossible Java int value using ret != |
| 494 | +Math.floor(ret) if the parent implements PropertyChangeListeneer, or -1 |
| 495 | +(CLOSE_OPTION) if not. |
| 496 | + |
| 497 | +For showOptionDialog (which returns Object) or showInputDialog (which returns |
| 498 | +String), the initial return will be JDialog.ASYNCHRONOUS_OBJECT, testable as |
| 499 | +((Object) ret) instanceof javax.swing.plaf.UIResource if the parent implements |
| 500 | +PropertyChangeListeneer, or null if not. |
| 501 | + |
| 502 | +The second return will be the desired return. |
| 503 | + |
| 504 | +In Java: |
| 505 | + |
| 506 | +The initial return will be the one and only modal final return. |
| 507 | + |
| 508 | + |
| 509 | + |
| 510 | +For full compatibility, The calling method must not continue beyond this |
| 511 | +call. |
| 512 | + |
| 513 | +All of the standard Java events associated with Components are also |
| 514 | +available. |
| 515 | + |
| 516 | +Certain fall back mechanisms are possible, where onReturn does not exist, but |
| 517 | +only for the falling cases: |
| 518 | + |
| 519 | + |
| 520 | +For showMessageDialog, for WARNING_MESSAGE and ERROR_MESSAGE, a simple |
| 521 | +JavaScript alert() is used, returning 0 (OK_OPTION) or -1 (CLOSED_OPTION). |
| 522 | + |
| 523 | +For showInputDialog, if the message is a string, a simple JavaScript prompt() |
| 524 | +with input box is used, returning the entered string or null. |
| 525 | + |
| 526 | +For showConfirmDialog, a simple JavaScript confirm() is used, in which case: |
| 527 | + |
| 528 | +for YES_NO_OPTION: YES_OPTION or NO_OPTION |
| 529 | + |
| 530 | +for YES_NO_CANCEL_OPTION: YES_OPTION or CANCEL_OPTION |
| 531 | + |
| 532 | +for OK_CANCEL_OPTION or any other: OK_OPTION or CANCEL_OPTION |
| 533 | + |
| 534 | +Note that you should implement a response for CLOSED_OPTION for |
| 535 | +showConfirmDialog. For other dialogs, a null return indicates the dialog was |
| 536 | +closed, just as for Java. |
| 537 | + |
| 538 | + |
462 | 539 |
|
463 | 540 |
|
464 | 541 | native methods |
|
0 commit comments