使用 JOptionPane
如果我使用 JOptionPane 消息对话框,我如何能够在消息部分显示整个数组,例如这个小 snipit?或者这可能吗?
public void showTheMessage()
{
JOptionPane.showMessageDialog(null,"These are are all the colors to
choosfrom,\n"+ arrayOfcolors[the whole array], "Color box");
}
if i was using a JOptionPane message dialog box how would I be able to show an the whole array in the message section such as this little snipit? or would that evenbe possible?
public void showTheMessage()
{
JOptionPane.showMessageDialog(null,"These are are all the colors to
choosfrom,\n"+ arrayOfcolors[the whole array], "Color box");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的事情是将数组的所有元素连接成一个大字符串。
The easiest thing to do would be to concatenate all the elements of the array into one big string.
showOptionDialog 方法允许用户从选项数组中选择单个元素,我认为这就是您的意思寻找。
The showOptionDialog method lets the user select a single element from an array of options, which I think is what you're looking for.
如果它是一个 Color 对象数组,
否则如果它是一个 String 对象数组,
请注意,使用 StringBuilder 会快得多,但我猜这只是一个小数组。
In case its an array of Color objects
Otherwise if its an array of String objects
Just a note, using StringBuilder is much faster, but this is just a small array i guess.