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 9103533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:39:14+00:00 2026-06-17T01:39:14+00:00

Beginner question . . . I want to run a boolean test on a

  • 0

Beginner question . . . I want to run a boolean test on a GImage object, but I don’t know how. For example, if my GImage is displaying “image1.jpg” file, I want to do ‘a’. But if it is displaying anything else, I want to do ‘b’. The images are being selected randomly by a different part of my program. The only way I can see to do this is to just create a placeholder String variable that I modify anytime that I change the GImage (and then I can just perform the test on the placeholder variable), but I’m sure is not the best way to do what I want. For example, the following would work, but because my actual program has a lot of relevant GImage objects and possible images, this approach would be very unwieldy:

GImage image1 = new GImage("bar.jpg", 0, 0);
int var1 = 0;
GImage image2 = new GImage("sunset.jpg", 100, 0);
int var2 = 1;
GImage image3 = new GImage("bar.jpg", 200, 0);
int var3 = 0;
if (var1 == 0) {
    // returns true
}
if (var2 == 0) {
    // returns false
}
if (var3 == 0) {
    // returns true
}

I am just learning to program, so there may be an obvious solution, but I can’t seem to find it. If there was a method that returned the filename displayed by a GImage, that would seem accomplish what I need, but I couldn’t find such a method. Thanks for your help.

  • 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-06-17T01:39:15+00:00Added an answer on June 17, 2026 at 1:39 am

    You could wrap the image in your own class, which contains appropriate attributes.

    Quick and dirty:

    class MyImage
    {
        private String resourceName;
        private GImage gImage;
    
        public MyImage(String resourceName,int x, int y){
            this.resourceName = resourceName;
            this.gImage = new GImage(resourceName,x,y)
        }
    
        public String getResourceName()
        {
            return resourceName;
        }
    
        //.
        //.
        //.
    }
    
    
    public static final String RES_IMG_SUNSET = "sunset.jpg";
    
    //.
    //.
    //.
    
    MyImage image1 = new MyImage("bar.jpg", 0, 0);
    MyImage image2 = new MyImage(RES_IMG_SUNSET, 100, 0);
    MyImage image3 = new MyImage("bar.jpg", 200, 0);
    
    if(image2.getResourceName().equals(RES_IMG_SUNSET))
    {
    }
    

    You might want to have some sort of unique resource names, so you could use normalized, canonical filenames or URI’s. Another way would be to define a global constant for these names, as in above example. Of course, GImage must support that format.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It may be a beginner question but I want to know, What is the
I know this is a very beginner question, but I'm obviously a beginner. I
Beginner question here! look at picture, I want the butten-edittext-button to fill the width
am sorry for this dumb beginner question, but i have a real problem understanding
This is a very beginner question. I have tried to search for advice but
I don't use Python regularly, but now I have to. I should run a
This is a very basic question, I know, but I cannot seem to figure
Hello bash beginner question. I want to look through multiple files, find the lines
This is surely a JS beginner question. My issue is I want to use
Sorry for asking such an easy question, but im a beginner I was following

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.