java - Java:JOptionPane showInputDialog 和 2 个输入
问题描述
我正在使用 NetBeans (Swing),我需要在同一个对话框中获取名字和姓氏(因此可以由用户编辑并保存)。我该怎么做呢?使用下面的代码,它们会出现在自己的对话框中,但其他一切正常。
private void editName(java.awt.event.ActionEvent evt) {
String newName = JOptionPane.showInputDialog(this, "Name", people.get(current).getFirstName());
if (newName != null)
people.get(current).setFirstName(newName);
update(people.get(current));
newName = JOptionPane.showInputDialog(this, "LastName", people.get(current).getLastName());
if (newName != null)
people.get(current).setLastName(newName);
update(people.get(current));
}
解决方案
推荐阅读
- r - 如果字符串匹配另一个字符串的一部分,则替换字符串
- javascript - 使用常量操作道具与使用函数操作道具有什么区别?
- pine-script - 带有颜色变化松树脚本的警报
- php - Xdebug - 在 Step Debugging 中增加 var_display_max_depth
- asp.net - 使用 Entity Framework 和 AutoMapper 实现 ?include=attributes 查询字符串
- php - 带有 jQuery 和 Canvas 的轻量级签名板 - Drawpad
- ios - SKPaymentQueue finishTransactions 未从队列中删除交易
- python - KivyMD + Python 中的 Matplotlib 线图:TypeError:actualizar_timeline_ventas() 采用 1 个位置参数,但给出了 2 个
- c++ - 如何使用 avcodec 和 libx264 设置固定 (const) fps
- prestashop - 禁用基于 zip 的运输方式,如何在 tpl 中获取 zip