Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.         ImageIcon icon1 = new ImageIcon("src/halum/lesson.gif");
  2.         ImageIcon icon2 = new ImageIcon("src/halum/lesson1-1.jpg");
  3.        
  4.         JButton button1 = new JButton(icon1);
  5.         JButton button2 = new JButton(icon2);
  6.         JButton button3 = new JButton(icon1);
  7.        
  8.         if(icon1.equals(icon2)) {
  9.             System.out.println("This line ain't gonna be shown dude. Because...");
  10.         }else {
  11.             System.out.println("They ain't same object you know :| ");
  12.         }
  13.        
  14.         if (button1.getIcon()==button2.getIcon()) {
  15.             System.out.println("This is a better method. but They ain't same.");
  16.         }else {
  17.             System.out.println("Not gonna be printed");
  18.         }
  19.        
  20.         if(button1.getIcon() == button3.getIcon()) {
  21.             System.out.println("this is true");
  22.             System.out.println("So this is what you should use");
  23.         }else {
  24.             System.out.println("Do we really need this else?");
  25.         }
  26.        
  27.         if (button1.getIcon().equals(button3.getIcon())) {
  28.             System.out.println("This should work as well. As both buttons use same image icon");
  29.         }