John Jared
John Jared

Reputation: 800

Java dialog with text and button

How do I make a dialog that has a text at the top and under it a blank space where the user can type and under it on the right an OKAY button where when you click on it the dialog disappears?

Like this:

Input dialog

Upvotes: 1

Views: 2865

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168845

String input = JOptionPane.showInputDialog(..);

For more information see How to Make Dialogs. Here is an example from that document.

String s = (String)JOptionPane.showInputDialog(
                this,
                "Complete the sentence:\n"
                + "\"Green eggs and...\"",
                "Customized Dialog",
                JOptionPane.PLAIN_MESSAGE,
                null,
                null,
                "ham");

JOptionPane requesting input

Upvotes: 4

Related Questions