Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:57:44+00:00 2026-05-27T06:57:44+00:00

I ran into an issue while I’m making a 4 player chess game. I

  • 0

I ran into an issue while I’m making a 4 player chess game. I am unable to see if two ImageIcons are the same. I have four arrays for the red, blue, green, and yellow pieces and my idea was to see if what piece the player clicked on matched any of the pieces in their color array. However if I say like if(colorIcon.equals(clickedIcon)) it returns false. I know that is because .equals() refers to the reference and I’m making new space in the memory. So is there any way I can compare two ImageIcons? Thanks for reaading!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:57:45+00:00Added an answer on May 27, 2026 at 6:57 am

    You can always do:

    public class MyImageIcon extends ImageIcon{
       String imageColor;
       // Getters and setters...  
       // Appropriate constructor here.
       MyImageIcon(Image image, String description, String color){
           super(image, description);
           imageColor = color;
       }
       @Override
       public bool equals(Object other){
          MyImageIcon otherImage = (MyImageIcon) other;
          if (other == null) return false;
          return imageColor == other.imageColor;
       }
    }
    

    And use this class instead of a raw ImageIcon

    Instead of having:

    ImageIcon myImage = new ImageIcon(imgURL, description);
    

    you would have:

    MyImageIcon myImage = new MyImageIcon (imgURL, description, "RED");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ran into an interesting issue while trying to create a more usable
While writing a game for J2ME we ran into an issue using java.lang.Integer.parseInt() We
I ran into a strange issue over the weekend while I was working on
I ran into an issue while compiling an openGl code. The thing is that
A co-worker ran into an interesting issue today, and while I think the actual,
Yesterday I ran into an Issue while developing a Web Part (This question is
I've ran into an issue while trying to put together a Grails app with
I have ran into a really annoying issue which gives me this error: The
I have a bit complex to explain issue that I have ran into: I
While working on my own type erasure iterator, I ran into an issue where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.