For most part JOptionPane
is extremely flexible, for example, starting with something as simple as...
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
public class TestPane extends JPanel {
public TestPane() {
setLayout(new GridBagLayout());
setBorder(new EmptyBorder(32, 32, 32, 32));
JLabel label = new JLabel("Hello world");
label.setFont(label.getFont().deriveFont(32f));
add(label);
}
}
I can do...

JOptionPane.showMessageDialog(null, new TestPane());
Ah, but wait, you probably don't want the icon, so instead you can do something like...

JOptionPane.showMessageDialog(null, new TestPane(), "Hello", JOptionPane.PLAIN_MESSAGE);
... what do you mean, you want custom options?! Well, okay, JOptionPane
can handle that as well...

String[] options = new String[]{
"options",
"your",
"are",
"These"
};
int result = JOptionPane.showOptionDialog(null, new TestPane(), "Hello", JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[3]);
if (result >= 0) {
System.out.println(options[result]);
}
Now, with a little bit of thought and effort, you could also:
JOptionPane
is a good option, but it's not the only option you have. You could roll your own "factory" (like JOptionPane
) that did all the heavy lifting of building a JDialog
, generating the buttons/options and handling user input (on those actions)