how to change the width of Joptionpane.showInputDialog?

Asked

Viewed 179 times

0

Would you like to know how to increase the width of the inputDialog inbox? I am using the code below to open the dialog box to edit an information called "title", is working, but the title can be a little long and so I would like the dialog box to be wider.

String answer = (String)Joptionpane.showInputDialog(null,"Title Edit:", "Title Edit",Joptionpane.PLAIN_MESSAGE, null,null,"Title");

1 answer

0


UIManager is a utility class of the Swing library, in which you can change the properties of the elements by setting values through keys and values (as well as a Hashmap, for example).

To change the minimum size of an Optionpane, you can change the property OptionPane.minimumSize, staying that way:

UIManager.put("OptionPane.minimumSize", new Dimension(500, 50));

String resposta = (String)JOptionPane.showInputDialog(null,"Edição de título:", "Editar Título",JOptionPane.PLAIN_MESSAGE, null,null,"Título");

You can see the documentation for the Uimanager class here, and the properties here.

  • 1

    It worked perfectly. Only it changes to the other Joptionpane too, but then just reset the size to normal. Thanks for the information, this seemed to me more practical and efficient of the solutions I found.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.