BobHanson / java2script

Java2Script provides an Eclipse Java to JavaScript transpiler, with a nearly complete implementation of the Java Virtual Machine with AWT and Swing in JavaScript, with simple, automated parallel creation of both class files and js files. To date, over 600 applets have been converted.

Home Page:https://chemapps.stolaf.edu/swingjs/examples.htm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OptionPaneUI does not connect event handlers properly

warownia1 opened this issue · comments

Dialogs (and internal frame dialogs) created by the JOptionPane do not react to the button presses. It is likely the issue of OptionPaneUI not triggering JOptionPane's property change listeners on button clicks.

Example code:

public class DialogsTest extends JFrame
{  
  DialogsTest() {
    super();
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setBounds(0, 0, 800, 600);
    setVisible(true);
    setContentPane(new JDesktopPane());

    var pane = new JOptionPane("I'm a banana");
    var dialog = pane.createDialog(getContentPane(), "Hello!");
    dialog.setVisible(true);
  }
    
  public static void main(String[] args) {
    SwingUtilities.invokeLater(DialogsTest::new);
  }
}

Clicking OK button closes the dialog in java, but does nothing in javascript.

not seeing this. perhaps fixed at some point. Note that using this motif, JavaScript does not wait. You would need to subclass JDesktopPane to implement PropertyChangeListener and look for the "value" property being passed to it. The standard

    JOptionPane.showMessageDialog(this, "I'm a Banana");

works as expected.