Using Input Dialogues in Applets
The code of the input applet follows a pair of screenshots for the running applet.
![]() Input dialogue applet (280 x 180) in action |
![]() Second dialogue |
namespace input_dialog_demo; interface uses java.util, java.applet.*, java.awt.*, javax.swing; type InputDialogDemo = public class(Applet, ActionListener) private btnInput : Button; public method init; override; method actionPerformed(e : ActionEvent); end; implementation method InputDialogDemo.init; begin Background := Color.green.darker; btnInput := new Button('Get Input'); add(btnInput); btnInput.addActionListener(self); end; method InputDialogDemo.actionPerformed(e : ActionEvent); var strInput : String; begin if e.getSource = btnInput then begin strInput := JOptionPane.showInputDialog(self, 'Please type your input.'); JOptionPane.showMessageDialog(self, 'You typed ' + strInput, 'Your Input', JOptionPane.INFORMATION_MESSAGE); end; end; end.