1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public class OptionPaneLocation
{
private void createAndDisplayGUI()
{
JOptionPane optionPane = new JOptionPane("Its me"
, JOptionPane.PLAIN_MESSAGE
, JOptionPane.DEFAULT_OPTION
, null, null, "Please ENTER your NAME here");
optionPane.setWantsInput(true);
JDialog dialog = optionPane.createDialog(null, "TEST");
dialog.setLocation(10, 20);
dialog.setVisible(true);
System.out.println(optionPane.getInputValue());
}
public static void main(String... args)
{
Runnable runnable = new Runnable()
{
public void run()
{
new OptionPaneLocation().createAndDisplayGUI();
}
};
SwingUtilities.invokeLater(runnable);
}
} |
Partager