首页 > 解决方案 > 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));           
    }

标签: javaswing

解决方案


推荐阅读