01: package com.xoetrope.carousel.services.dialog;
02:
03: import javax.swing.BoxLayout;
04: import javax.swing.JLabel;
05: import javax.swing.JOptionPane;
06: import javax.swing.JPanel;
07: import javax.swing.JTextField;
08:
09: /**
10: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
11: * the GNU Public License (GPL), please see license.txt for more details. If
12: * you make commercial use of this software you must purchase a commercial
13: * license from Xoetrope.</p>
14: * <p> $Revision: 1.2 $</p>
15: */
16: public class InputDialog {
17:
18: public static String showDialog(String prompt, String title,
19: String initValue) {
20: JPanel panel = new JPanel();
21: panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
22: JTextField txtInput = new JTextField(initValue);
23: panel.add(new JLabel(prompt));
24: panel.add(txtInput);
25: int result = JOptionPane.showConfirmDialog(null, panel, title,
26: JOptionPane.OK_CANCEL_OPTION);
27: if (result == 0)
28: return txtInput.getText();
29: else
30: return null;
31: }
32: }
|