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

  • Home
  • SEARCH
  • 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 9005721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:13:12+00:00 2026-06-16T01:13:12+00:00

just need a little help locating an error(?) in my code, is set the

  • 0

just need a little help locating an error(?) in my code, is set the default of the boolean avtive to false but when i run the code, it mysteriously becomes true

    import javax.swing.*;
    import java.awt.*;
    import java.net.URL;

    @SuppressWarnings("serial")
    public class openScreenBuild extends JPanel{
    String picPath = "pictures/";
    String[] fileName = { "openScreen.png", "playButtonPress.png",
    "playButtonRelease.png", "playButtonInactive.png" };
    ClassLoader cl = openScreenBuild.class.getClassLoader();
    URL imgURL[] = new URL[4];
    Toolkit tk = Toolkit.getDefaultToolkit();
    Image imgBG, imgPlayPress, imgPlayRelease, imgPlayInactive;
    Boolean active=false, playPress = false;

    public openScreenBuild() throws Exception {
        for (int x = 0; x < 4; x++) {
            imgURL[x] = cl.getResource(picPath + fileName[x]);
        }
        imgBG = tk.createImage(imgURL[0]);
        imgPlayPress = tk.createImage(imgURL[1]);
        imgPlayRelease = tk.createImage(imgURL[2]);
        imgPlayInactive = tk.createImage(imgURL[3]);
    }
    public void updateScreen(){
        repaint();
    }
    public void paintComponent(Graphics g) {
        g.drawImage(imgBG, 0, 0, 600, 460, 0, 0, 600, 460, this);
        if (active=true){
            if (playPress == false)
                g.drawImage(imgPlayRelease, 410, 355, 590, 450, 0, 0, 163, 87, this);
            else if (playPress == true)
                g.drawImage(imgPlayPress, 410, 355, 590, 450, 0, 0, 163, 87, this);
            System.out.println("Active");
        }
        else if(active=false){
            g.drawImage(imgPlayInactive, 410, 355, 590, 450, 0, 0, 163, 87, this);
            System.out.println("Inactive");
        }
        g.setColor(Color.WHITE);
        g.drawString("ABOUT PROGRAM STUFF", 25, 375);
    }
    public void checkCoord(Point point){
        int xPos=(int)point.getX();
        int yPos=(int)point.getY();
        if (active==true){
            if ((yPos>=355)&&(yPos<=450)&&(xPos>=410)&&(xPos<=590))
                playPress=true;
        }
        updateScreen();
    }
    public void resetScreen(){
        playPress=false;
        updateScreen();
    }
}

As you can see, if active is false it should show a inactive play button image but if its true then it does the click/release images. Also it outputs in the System box(?)(Not sure what its called) if its active or not active

  • 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-16T01:13:13+00:00Added an answer on June 16, 2026 at 1:13 am
     if (active=true)
    

    assigns active to true. You want:

     if (active==true)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just getting started with Code Contracts, and need a little help in
I'm just figuring out my way around rails but I need a little help
I just need a little help how to organize my code. This is not
guess its getting late, and Im a beginner, just need a little help.. Im
I need a little help with my code here. So far, when I go
i just need a little help on how i could implement this function. i
I just need little help, that is: many times i have seen http://www.xyz.com/index.jsp?etetet%rr^_frfwrw.... .
Need a little help with this script. It's working but I'd love a way
I am not a regex guy, so I need a little help, just cant
I'm so close on this one, but I need a little help. I have

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.