Swing for GUI输入

时间:2014-06-03 21:54:40

标签: java swing

再次提出初学者问题!当运行以下时,即使输入了正确的名称“matthew”,我也会出现“False”对话框。

我肯定错过了一些东西!

import javax.swing.*;

public class IfStatmentString
{
    public static void main(String[] args)
    {
        String name = "";
        name = JOptionPane.showInputDialog(null, "Please enter User Name:","Name",JOptionPane.QUESTION_MESSAGE);

        if (name == "matthew" )
        {
            JOptionPane.showMessageDialog(null,"True");
        }

        else
        {
            JOptionPane.showMessageDialog(null,"False");
        }
    }

}

0 个答案:

没有答案