public static String inputBox(String title, String prompt, String text) {
final Dialog dlgInput = new Dialog();
dlgInput.setTitle(title);
dlgInput.setLayout(new TableLayout(new double[][] { { 0, 60, 60 },
{ 20, 20, 20 } }, 5, 5));
dlgInput.setHeight(100);
dlgInput.getChildren().add(new Label(prompt).setLimit("0,0,3,1"));
final TextField tfInput = new TextField(text);
dlgInput.getChildren().add(tfInput.setLimit("0,1,3,1"));
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent ev) {
Button button = (Button) ev.getSource();
if (button.getUserObject().equals("CANCEL")) {
tfInput.setText("");
}
dlgInput.setVisible(false);
}
};
Button btnOk = new Button("Ok");
btnOk.setUserObject("OK");
btnOk.addActionListener(Component.ACTION_CLICK, actionListener);
dlgInput.getChildren().add(btnOk.setLimit("1,2"));
Button btnCancel = new Button("Cancel");
btnCancel.setUserObject("CANCEL");
btnCancel.addActionListener(Component.ACTION_CLICK, actionListener);
dlgInput.getChildren().add(btnCancel.setLimit("2,2"));
dlgInput.setWaitForWindow(true);
dlgInput.setVisible(true);
return tfInput.getText();
}
////////////////////////////////////////////////
bye frank_lupo
Logged In: NO
add event enter keypress
tfInput.addKeyPressListener("Enter", new KeyPressListener() {
public void keyPress(KeyPressEvent ev) {
dlgInput.setVisible(false);
}
});
Logged In: NO
bye frank_lupo
why not just create a TextField and include it on a MessageBox.confirm and pass the TextField in as the 3rd paramater?