1+ package test ;
2+
3+ import java .beans .PropertyChangeEvent ;
4+ import java .beans .PropertyChangeListener ;
5+
6+ import javax .swing .JDesktopPane ;
7+ import javax .swing .JDialog ;
8+ import javax .swing .JFrame ;
9+ import javax .swing .JOptionPane ;
10+ import javax .swing .SwingUtilities ;
11+
12+ import javajs .async .SwingJSUtils ;
13+
14+ public class DialogsTest extends JFrame {
15+
16+ private class PCLPane extends JDesktopPane implements PropertyChangeListener {
17+ @ Override
18+ public void propertyChange (PropertyChangeEvent evt ) {
19+ String name = evt .getPropertyName ();
20+ System .out .println (name );
21+ if (name .equals ("value" )) {
22+ handlePropEvent (evt .getNewValue ());
23+ }
24+ }
25+ }
26+
27+ DialogsTest () {
28+ setDefaultCloseOperation (EXIT_ON_CLOSE );
29+ setBounds (0 , 0 , 800 , 600 );
30+ setVisible (true );
31+ // For JavaScript, we need a property change listener.
32+ setContentPane (new PCLPane ());
33+
34+ JOptionPane pane = new JOptionPane ("I'm a banana" );
35+ JDialog dialog = pane .createDialog (getContentPane (), "Hello!" );
36+ dialog .setVisible (true );
37+ if (/** @j2sNative false && */
38+ true )
39+ report ("done" );
40+ // JavaScript continues....
41+ }
42+
43+ public void handlePropEvent (Object newValue ) {
44+ System .out .println ("value was " + newValue );
45+ report ("done" );
46+ }
47+
48+ private void report (String string ) {
49+ System .out .println (string );
50+ JOptionPane .showMessageDialog (this , "I'm a Banana" );
51+ System .out .println ("ok" );
52+
53+ }
54+
55+ public static void main (String [] args ) {
56+ SwingUtilities .invokeLater (DialogsTest ::new );
57+ }
58+
59+ }
0 commit comments