【问题标题】:How to check whether the two JButton have same ImageIcon?如何检查两个JButton 是否有相同的ImageIcon?
【发布时间】:2014-04-29 06:02:09
【问题描述】:
 public void actionPerformed(ActionEvent e)
{
    if ((button1.getIcon()==button2.getIcon())
        && (button2.getIcon()==button3.getIcon())
        && (button1.getIcon()!=null))
    {
        win=true;
        JOptionPane.showMessageDialog(null,"win");
    }
}
//am not able to perform this action.

【问题讨论】:

    标签: java swing icons compare jbutton


    【解决方案1】:

    尝试使用equals() 方法而不是使用== 进行比较。

    【讨论】:

      猜你喜欢
      • 2023-03-13
      • 2011-06-22
      • 2014-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多