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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:11:49+00:00 2026-06-11T22:11:49+00:00

Mac OSX Netbeans JAVA Goal: BlackJack program… Im trying to get an imageIcon of

  • 0

Mac OSX
Netbeans
JAVA

Goal: BlackJack program… Im trying to get an imageIcon of a Playing Card to display in a JLabel

Logic:
I have created some CARD objects with a method to return the imageIcon associated with it.
In my main GUI class it works if i create the new imageIcon specifying the file location –

    private void newGame(){

    String temp1, temp2, temp3, temp4;

    card1 = hand.dealHand();
    card2 = hand.dealHand();
    card3 = hand.dealHand();
    card4 = hand.dealHand();

    image1 = new ImageIcon();
    image1 = card1.getImage();


    //Creates DeckImage and Logo as JLabel and adds it to userPanel

    //image1 = new ImageIcon("/Users/philhunter/NetBeansProjects/PractingProgramming/src/Resources/1.png");


    card1Label = new JLabel(image1, JLabel.LEFT);
    userPanel.add(card1Label);

    card1Label.setText("");

}

The commented out line works fine and displays the imageIcon image but when I use the card1.getImage() method then the image does not display. The method is simply –

public ImageIcon getImage(){
    return this.image;
}

Also, in case you need it, here is the method that creates the CARD’s from the DECK class –

private ImageIcon C1,C2, ... ,C52;
private ImageIcon[] imageArray= { C1,C2,...,C52 };
C1 = new ImageIcon("/Users/philhunter/NetBeansProjects/PractingProgramming/src/Resources/1.png");
...
C52 = new ImageIcon("/Users/philhunter/NetBeansProjects/PractingProgramming/src/Resources/52.png");

int SUITS = suit.length;
    int RANKS = rank.length;
    int N = SUITS * RANKS;

    //Creates a deck of 52 CARD objects
    theDeck = new CARD[N];
    for (int i = 0; i < RANKS; i++) {
        for (int j = 0; j < SUITS; j++) {
            //deck[SUITS*i + j] = rank[i] + " of " + suit[j];
            card = new CARD(suit[j], rank[i], value[i], imageArray[SUITS*i + j]);
            theDeck[SUITS*i + j] = card;
        }
    }

So my question is why does the card imageIcon not display? (I am getting no error messages)

  • 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-11T22:11:50+00:00Added an answer on June 11, 2026 at 10:11 pm

    Ok, so I found the problem. I hadn’t initialized the array imageArray[] with the imageIcons properly. Silly mistake but I thought I would leave this up in case other people make this silly mistake too. 🙂

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

Sidebar

Related Questions

On Mac OSX 5.8 I have a Java program that runs at 100% CPU
I am running Mac OSX lion and have a Java project in netbeans where
Setup Mac OSX 10.6.7, Eclipse, Tomcat 1.6 I am trying to call a string
So I'm running Mac OSX Lion and I recently installed Eclipse IDE for Java
I am running Mac OSX 10.5.8. I installed matplotlib using macports. I get some
I (on mac osx) often use export http_proxy=http://192.168.0.205:1099 to proxy http connection to get
I am running Mac OS X 10.5.8 and am trying to run Netbeans 7.1.2.
I'm new to Netbeans on Mac OSX, and i want to use the control-A/E
I'm using NetBeans 6.9.1 on Mac OS X 10.6.4 with Java 1.6.0_22. I have
Environment: Mac osx lion Grails version: 2.1.0 Java: 1.7.0_08-ea If I start up vertx

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.