简体   繁体   中英

Prompt User command in java - controlling the size of the prompt box

I wanted to know how to control the size of the prompt box when using such command:

int p = promptUserForInput ("enter the number of sugar you want for your coffee?", 0 )

When I am writing this, the box opening is cutting the title-question. How can I request that the box fit the sentence?

It's javax.swing.JOptionPane.showInputDialog ? I generally put some extra spaces at the end of the input string as java regularly messes up the calculation of the number of pixesls representing the number of characters in the string.

An alternative is to break the message up into multiple lines using the \\n character, or reword it to a smaller option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM