简体   繁体   English

Java中的“提示用户”命令-控制提示框的大小

[英]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 ? 这是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. 我通常在输入字符串的末尾放置一些额外的空格,因为java会定期弄乱代表字符串中字符数的像素数的计算。

An alternative is to break the message up into multiple lines using the \\n character, or reword it to a smaller option. 一种替代方法是使用\\n字符将消息分成多行,或将其改写为较小的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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