尝试使用一个组合盒保存joptionpane,并在字符串中产生一个字符串,但它使我无法转换为字符串”。
这是给我错误的代码:
private void btnLLamada1ActionPerformed(java.awt.event.ActionEvent evt) {
minutos = Integer.parseInt(JOptionPane.showInputDialog(null, "numero de minutos"));
String[] lista = {"Local", "Internacional", "Celular"};
JComboBox optionList = new JComboBox(lista);
optionList.setSelectedIndex(0);
tp = JOptionPane.showMessageDialog(null, optionList, "Que tipo de llamada va a usar",
JOptionPane.QUESTION_MESSAGE);
}
here is the code that gives me error:
private void btnLLamada1ActionPerformed(java.awt.event.ActionEvent evt) {
minutos = Integer.parseInt(JOptionPane.showInputDialog(null, "numero de minutos"));
String[] lista = {"Local", "Internacional", "Celular"};
JComboBox optionList = new JComboBox(lista);
optionList.setSelectedIndex(0);
tp = JOptionPane.showMessageDialog(null, optionList, "Que tipo de llamada va a usar",
JOptionPane.QUESTION_MESSAGE);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
joptionpane.showmessagedialog(...)
不会返回任何内容,因此它返回void
。没有什么(void
)不能转换为字符串。您要使用方法showInputDialog
。为了灵感,请查看(docs.oracle.com/javase.com/javase/tutorial /uiswing/组件/…。
JOptionPane.showMessageDialog(...)
does not return anything hence it returnsvoid
. And nothing (void
) cannot be converted into a string. You want to use the methodshowInputDialog
. For inspiration look at (docs.oracle.com/javase/tutorial/uiswing/components/….A short executable hack to show the dialogs: