각 텍스트 필드에서 작업 수신기를 확인하십시오. 나는 많은 테스트를 수행했으며 액션 리스너를 추가하는 것이 문제가 아니라는 것을 발견했습니다. 문제는 어딘가 아래 코드에 있습니다. 왜냐하면 상위 4 개의 텍스트 필드에 hello 창이 나타나지만 확인에는 나타나지 않기 때문입니다. 하지만 아래쪽에있는 ok 창과 hello 창이 나타납니다. 나는 무엇을 잘못 했는가?자바에서 적절한 조치를 취하는 데 도움이 필요합니다.
public class handler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
if (event.getSource() == text)
{
JOptionPane.showMessageDialog(null, "ok");
}
else if (event.getSource() == text1)
{
JOptionPane.showMessageDialog(null, "ok");
}
else if (event.getSource() == text2)
{
JOptionPane.showMessageDialog(null, "ok");
}
else if (event.getSource() == text3)
{
JOptionPane.showMessageDialog(null, "ok");
}
else if (event.getSource() == text4)
{
JOptionPane.showMessageDialog(null, "ok");
}
JOptionPane.showMessageDialog(null, "hello");
}
}
'=='대신'.equals (...) '를 사용 해보고 예상되는 행동은 정확히 무엇입니까? –