If converting the code is giving you problems, perhaps another approach would help.
Write a small simple program with a frame, a button and a listener for that button. Put a call to JOptionPane in...