How do i make Images show ?

Hello :) I'm writing a simple game but I am having so much trouble with it :( here is the code now all it does right now is it writes out the values of the cards on the screen in an applet however I want it to display card images from http://www.waste.org/~oxymoron/cards
i can't get it to use the string values and give me the card images instead of text... please help a woman in trouble ;O) thank you
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
//import java.applet.*;
///import java.util.*;
public class HighLowGUI extends JApplet {
//private HighLowGUI label = new HighLowGUI("Socrates");      // CyberPet
    //private JLabel nameLabel = new JLabel("Hi! My name is ");
    //private TextField stateField = new TextField(12);      // A TextField
   public void init() {
         // The init() method lays out the applet.
         // A HighLowCanvas occupies the CENTER position of the layout.
         // On the bottom is a panel that holds three buttons.  The
         // HighLowCanvas object listens for ActionEvents from the
         // buttons and does all the real work of the program.
      setBackground( new Color(130,50,40) );
      HighLowCanvas board = new HighLowCanvas();
      getContentPane().add(board, BorderLayout.CENTER);
      JPanel buttonPanel = new JPanel();
      buttonPanel.setBackground( new Color(220,200,180) );
      getContentPane().add(buttonPanel, BorderLayout.SOUTH);
      JButton higher = new JButton( "Deal" );
      higher.addActionListener(board);
      buttonPanel.add(higher);
      JButton newGame = new JButton( "New Game" );
      newGame.addActionListener(board);
      buttonPanel.add(newGame);
     // JLabel nameLabel = new JLabel("Hi! My name is ");
   }  // end init()
   class HighLowCanvas extends JPanel implements ActionListener {
         private Image eatImg, eat2Img, sleepImg, happyImg;     // Images for animation
        // A nested class that displays the cards and does all the work
         // of keeping track of the state and responding to user events.
      Deck deck;       // A deck of cards to be used in the game.
      Hand hand;       // The cards that have been dealt.
      String message;  // A message drawn on the canvas, which changes
                       //    to reflect the state of the game.
      boolean gameInProgress;  // Set to true when a game begins and to false
                               //   when the game ends.
      Font bigFont;      // Font that will be used to display the message.
      Font smallFont;    // Font that will be used to draw the cards.
      HighLowCanvas() {
            // Constructor.  Creates sets the foreground and
            // background colors, and starts the first game.
      setBackground( new Color(0,120,0) );
         setForeground( Color.yellow);
                 //  smallFont = new Font("SansSerif", Font.PLAIN, 12);
                  // bigFont = new Font("Serif", Font.BOLD, 14);
        doNewGame();
      } // end constructor
      public void actionPerformed(ActionEvent evt) {
             // Respond when the user clicks on a button by calling
             // the appropriate procedure.  Note that the canvas is
             // registered as a listener in applet's init() method.
         String command = evt.getActionCommand();
         if (command.equals("Deal"))
            doDeal();
         else if (command.equals("New Game"))
            doNewGame();
      } // end actionPerformed()
      void doDeal() {
               // Called by actionPerformmed() when user clicks "Higher" button.
               // Check the user's prediction.  Game ends if user guessed
               // wrong or if the user has made three correct predictions.
         if (gameInProgress == false) {
               // If the game has ended, it was an error to click "Higher",
               // So set up an error message and abort processing.
            message = "Click \"New Game\" to start a new game!";
            repaint();
            return;
         hand.addCard( deck.dealCard() );     // Deal a card to the hand.
         int cardCt = hand.getCardCount();
         Card thisCard = hand.getCard( cardCt - 1 );  // Card just dealt.
         Card prevCard = hand.getCard( cardCt - 2 );  // The previous card.
         if ( thisCard.getValue() < prevCard.getValue() ) {
            gameInProgress = false;
            message = "Too bad! You lose.";
         else if ( thisCard.getValue() == prevCard.getValue() ) {
            gameInProgress = false;
            message = "Too bad!  You lose"; // on ties
         else if ( cardCt == 4) {    //CHANGED+++++++++++++++++=
            gameInProgress = false;
           message = "You win! Hurra! ";
         else {
            message = "Got it right!  Try for " + cardCt + " Press  -Deal- ";
         repaint();
      } // end
      void doNewGame() {
             // Called by the constructor, and called by actionPerformed() if
             // the use clicks the "New Game" button.  Start a new game.
         if (gameInProgress) {
                 // If the current game is not over, it is an error to try
                 // to start a new game.
            message = "You still have to finish this game! Press   -Deal-";
            repaint();
            return;
         deck = new Deck();   // Create the deck and hand to use for this game.
         hand = new Hand();
         deck.shuffle();
         hand.addCard( deck.dealCard() );  // Deal the first card into the hand.
         message = "Deal your cards";
         gameInProgress = true;
         repaint();
      } // end doNewGame()
      public void paintComponent(Graphics g) {
            // This method draws the message at the bottom of the
            // canvas, and it draws all of the dealt cards spread out
            // across the canvas.  If the game is in progress, an
            // extra card is dealt representing the card to be dealt next.
         super.paintComponent(g);
              g.setFont(bigFont);
              g.drawString(message,10,135);
              g.setFont(smallFont);
         int cardCt = hand.getCardCount();
              for (int i = 0; i < cardCt; i++)
                    drawCard(g, hand.getCard(i), 10 + i * 90, 10);
         if (gameInProgress)
            drawCard(g, null, 10 + cardCt * 90, 10);
      } // end paintComponent()
      void drawCard(Graphics g, Card card, int x, int y) {
              // Draws a card as a 80 by 100 rectangle with
              // upper left corner at (x,y).  The card is drawn
              // in the graphics context g.  If card is null, then
              // a face-down card is drawn.  (The cards are
              // rather primitive.)
         if (card == null) {      // Draw a face-down card
            g.setColor(Color.blue);
            g.fillRect(x,y,80,100);
            g.setColor(Color.white);
            g.drawRect(x+3,y+3,73,93);
            g.drawRect(x+4,y+4,71,91);
         else {
            g.setColor(Color.white);
            g.fillRect(x,y,80,100);
            g.setColor(Color.gray);
            g.drawRect(x,y,79,99);
            g.drawRect(x+1,y+1,77,97);
         if (card.getSuit() == Card.DIAMONDS || card.getSuit() == Card.HEARTS)
            g.setColor(Color.red);
         else
            g.setColor(Color.black);
            g.drawString(card.getValueAsString(), x + 10, y + 30);
            g.drawString("of", x+ 10, y + 50);
            g.drawString(card.getSuitAsString(), x + 10, y + 70);
      } // end drawCard()
   } // end nested class HighLowCanvas
} // end class HighLowGUI
   An object of class card represents one of the 52 cards in a
   standard deck of playing cards.  Each card has a suit and
   a value.
public class Card {
    public final static int SPADES = 0,       // Codes for the 4 suits.
                            HEARTS = 1,
                            DIAMONDS = 2,
                            CLUBS = 3;
    public final static int ACE = 1,          // Codes for the non-numeric cards.
                            JACK = 11,        //   Cards 2 through 10 have their
                            QUEEN = 12,       //   numerical values for their codes.
                            KING = 13;
    private final int suit;   // The suit of this card, one of the constants
                              //    SPADES, HEARTS, DIAMONDS, CLUBS.
    private final int value;  // The value of this card, from 1 to 11.
    public Card(int theValue, int theSuit) {
            // Construct a card with the specified value and suit.
            // Value must be between 1 and 13.  Suit must be between
            // 0 and 3.  If the parameters are outside these ranges,
            // the constructed card object will be invalid.
        value = theValue;
        suit = theSuit;
    public int getSuit() {
            // Return the int that codes for this card's suit.
        return suit;
    public int getValue() {
            // Return the int that codes for this card's value.
        return value;
    public String getSuitAsString() {
            // Return a String representing the card's suit.
            // (If the card's suit is invalid, "??" is returned.)
        switch ( suit ) {
           case SPADES:   return "Spades";
           case HEARTS:   return "Hearts";
           case DIAMONDS: return "Diamonds";
           case CLUBS:    return "Clubs";
           default:       return "??";
    public String getValueAsString() {
            // Return a String representing the card's value.
            // If the card's value is invalid, "??" is returned.
        switch ( value ) {
           case 1:   return "A";
           case 2:   return "2";
           case 3:   return "3";
           case 4:   return "4";
           case 5:   return "5";
           case 6:   return "6";
           case 7:   return "7";
           case 8:   return "8";
           case 9:   return "9";
           case 10:  return "10";
           case 11:  return "J";
           case 12:  return "Q";
           case 13:  return "K";
           default:  return "??";
    public String toString() {
           // Return a String representation of this card, such as
           // "10 of Hearts" or "Queen of Spades".
        //return ""+"
        return getValueAsString() + " of " + getSuitAsString();
} // end class Card
    An object of type Deck represents an ordinary deck of 52 playing cards.
    The deck can be shuffled, and cards can be dealt from the deck.
public class Deck {
    private Card[] deck;   // An array of 52 Cards, representing the deck.
    private int cardsUsed; // How many cards have been dealt from the deck.
    public Deck() {       // Create an unshuffled deck of cards.
       deck = new Card[52];
       int cardCt = 0;    // How many cards have been created so far.
       for ( int suit = 0; suit <= 3; suit++ ) {
          for ( int value = 1; value <= 13; value++ ) {
             deck[cardCt] = new Card(value,suit);
             cardCt++;
       cardsUsed = 0;
    public void shuffle() {
          // Put all the used cards back into the deck, and shuffle it into
          // a random order.
        for ( int i = 51; i > 0; i-- ) {
            int rand = (int)(Math.random()*(i+1));
            Card temp = deck;
deck[i] = deck[rand];
deck[rand] = temp;
cardsUsed = 0;
public int cardsLeft() {
// As cards are dealt from the deck, the number of cards left
// decreases. This function returns the number of cards that
// are still left in the deck.
return 52 - cardsUsed;
public Card dealCard() {
// Deals one card from the deck and returns it.
if (cardsUsed == 52)
shuffle();
cardsUsed++;
return deck[cardsUsed - 1];
} // end class Deck
An object of type Hand represents a hand of cards. The maximum number of
cards in the hand can be specified in the constructor, but by default
is 5. A utility function is provided for computing the value of the
hand in the game of Blackjack.
import java.util.Vector;
public class Hand {
private Vector hand; // The cards in the hand.
public Hand() {
// Create a Hand object that is initially empty.
hand = new Vector();
public void clear() {
// Discard all the cards from the hand.
hand.removeAllElements();
public void addCard(Card c) {
// Add the card c to the hand. c should be non-null. (If c is
// null, nothing is added to the hand.)
if (c != null)
hand.addElement(c);
public void removeCard(Card c) {
// If the specified card is in the hand, it is removed.
hand.removeElement(c);
public void removeCard(int position) {
// If the specified position is a valid position in the hand,
// then the card in that position is removed.
if (position >= 0 && position < hand.size())
hand.removeElementAt(position);
public int getCardCount() {
// Return the number of cards in the hand.
return hand.size();
public Card getCard(int position) {
// Get the card from the hand in given position, where positions
// are numbered starting from 0. If the specified position is
// not the position number of a card in the hand, then null
// is returned.
if (position >= 0 && position < hand.size())
return (Card)hand.elementAt(position);
else
return null;
public void sortBySuit() {
// Sorts the cards in the hand so that cards of the same suit are
// grouped together, and within a suit the cards are sorted by value.
// Note that aces are considered to have the lowest value, 1.
Vector newHand = new Vector();
while (hand.size() > 0) {
int pos = 0; // Position of minimal card.
Card c = (Card)hand.elementAt(0); // Minumal card.
for (int i = 1; i < hand.size(); i++) {
Card c1 = (Card)hand.elementAt(i);
if ( c1.getSuit() < c.getSuit() ||
(c1.getSuit() == c.getSuit() && c1.getValue() < c.getValue()) ) {
pos = i;
c = c1;
hand.removeElementAt(pos);
newHand.addElement(c);
hand = newHand;
public void sortByValue() {
// Sorts the cards in the hand so that cards of the same value are
// grouped together. Cards with the same value are sorted by suit.
// Note that aces are considered to have the lowest value, 1.
Vector newHand = new Vector();
while (hand.size() > 0) {
int pos = 0; // Position of minimal card.
Card c = (Card)hand.elementAt(0); // Minumal card.
for (int i = 1; i < hand.size(); i++) {
Card c1 = (Card)hand.elementAt(i);
if ( c1.getValue() < c.getValue() ||
(c1.getValue() == c.getValue() && c1.getSuit() < c.getSuit()) ) {
pos = i;
c = c1;
hand.removeElementAt(pos);
newHand.addElement(c);
hand = newHand;

Please don't crosspost. It cuts down on the effectiveness of responses, leads to people wasting their time answering what others have already answered, makes for difficult discussion, and is generally just annoying and bad form.

Similar Messages

  • Since updating to FireFox 29. there are a lot of FaceBook Friend's posted photos are blank now. How do I make them show?

    Since updating to FireFox 29. there are a lot of FaceBook Friend's posted photos are blank now. How do I make them show?

    If images are missing then check that you do not block images from some domains.
    *Tap the Alt key or press F10 to show the Menu bar.
    Check the permissions for the domain in the currently selected tab in "Tools > Page Info > Permissions"
    Check "Tools > Page Info > Media" for blocked images
    *Select the first image link and use the cursor Down key to scroll through the list.
    *If an image in the list is grayed and "<i>Block Images from...</i>" has a checkmark then remove this checkmark to unblock images from this domain.
    Make sure that you do not block (third-party) images, the <b>permissions.default.image</b> pref on the <b>about:config</b> page should be 1.
    Make sure that you haven't enabled a High Contrast theme in the Windows/Mac Accessibility settings.
    Make sure that you allow pages to choose their own colors.
    *Tools > Options > Content : Fonts & Colors > Colors : [X] "Allow pages to choose their own colors, instead of my selections above"
    Note that these settings affect background images.
    See also:
    *http://kb.mozillazine.org/Website_colors_are_wrong
    There are extensions like Adblock Plus (Firefox/Tools > Add-ons > Extensions) and security software (firewall, anti-virus) that can block images and other content.
    See also:
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    *http://kb.mozillazine.org/Images_or_animations_do_not_load
    *http://kb.mozillazine.org/Websites_look_wrong

  • How do you make images transparent in inDesign?

    How do you make images transparent in Adobe InDesign CS5.5?

    Dittco wrote:
    It IS possible: Select the image. Open effects (Window > Effects). Switch from "normal" to "multiply". Viola! White background is gone.
    That only works with a white background. In addition, it introduces a transparency effect, with its associated problems.
    With a rather light background: Select the image. Open clipping path (Object > Clipping Path > Options). Select Type > Detect Edges; use Threshold and Tolerance to get as close as possible to the edge of your image. This may be difficult because of a too low resolution image, or too much fringe on the edge -- if all fails, use the Inset Frame value to force the mask "into" the image. Click OK, and the background is gone.
    But that's not the only way: you can always create a clipping path manually, and then you are in total control, not limited by transparency side effects, auto-edge detection, and busy backgrounds.

  • How can I make Spotlight show the file path

    How can I make Spotlight show the file path in the Spotlight menu for selected file?

    Via Finder certainly, but not in the menu.  You can view the file path in the Spotlight search results display by pressing the ⌘ key (while hovering over a file in the results), though.  The path will display at the bottom of the Quick Look output, or cycle through that location.

  • How do I make Mail show unread msgs in bold?

    Hi-
    In the preferences for Mail 5.1 there exists an option to "show unread messages with bold font". 
    Checked or unchecked the unread messages look just like read ones.
    Is there a fix for this?  I tried to make a Rule but couldn't find "is unread" on the list.
    Actually I would settle for almost any difference; background color, italic, font color.
    How do I make Mail show unread msgs differently?
    thanks in advance for your help.
    J2

    Some more ideas on Smart Mailboxes.
    Please note that a Smart Mailbox does not move any email. It is just a search that collects matching email and displays them all together. You can move emails from the Smart Mailbox, and it will move the email from wherever it happens to be, into the folder you drop it into (except another smart mailbox)
    You can create smart mailboxes to group emails by date, also. I've got Last Week, This Week, and This Month set up. Notice how you can drop smart mailboxes on top of one another to group them. It doesn't affect the search that is conducted, just puts them together. You can also add that group of Smart Mailboxes to the toolbar.
    I use smart mailboxes for certain mailing lists where I just want to read and delete the list email, not move it into a mailbox for long-term storage. So, I create a smart mailbox for those list emails and I can show all the ones I haven't read/deleted.

  • After sync my iphone4 to itunes i can't see the same apps on itunes that are on my phone.  How do i make them show the same?

    after sync my iphone4 to itunes i can't see the same apps on itunes that are on my phone.  How do i make them show the same?

    Hello Louise,
    There are a couple of ways that you can download your apps to iTunes on your computer. 
    First, you can transfer your purchases to from your iPhone to your computer using the steps in this article:
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer
    http://support.apple.com/kb/HT1848
    Alternatively, you can download the apps directly from the iTunes Store using the steps in this article:
    iTunes 11 for Windows: Download previous purchases from the iTunes Store
    http://support.apple.com/kb/PH12491
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • When i plug my SD card in my MAC it doesn't show my videos, only pictures. How can i make them show up?

    When i plug my SD card in my MAC it doesn't show my videos, only pictures. How can i make them show up?

    The following may help:
    Windows: http://support.apple.com/kb/TS1538
    Mac: http://support.apple.com/kb/TS1591

  • In Cover Flow, a compilation album shows different covers for each song.  How do I make it show one cover for the whole album?

    In Cover Flow, a compilation album shows different covers for each song.  How do I make it show one cover for the whole album?

    Also in the first page of Get Info for all tracks set the Album Artist to be Various Artists.
    If you select all the tracks and right click to get info then you can do all the tracks in one go

  • How do I make image icons in finder window previews of the image?

    The image icons in my finder window are just generic jpeg icons (they are set to open automatically in Preview). How do I make them previews of the images themselves? When I "get info" on the icon, there is a very nice preview of the image - I would like to see the same quality preview in the icons themselves.
    Thank you very much for your help.
    Sam
    Powerbook   Mac OS X (10.4.6)  

    Hi Sam,
    From your Finder "View" menu (without a Finder window open) >> "Show view options" >> do you have "show icon preview" check marked? And with the Finder window open "show icons" and "show preview icons" checkmarked?
    EDIT: I may have misunderstood your question. If you're talking about the small file icons, not in the preview frame if you have PhotoShop it should do it with a save as PS file. Otherwise you may be able to paste the image but I'm not sure.
    -mj
    [email protected]
    Message was edited by: macjack

  • HOW DO I MAKE IMAGES DYNAMIC USING DREAMWEAVER & MySql

    Hi there,
       I wanted to make images dynamic in that the images would be stored in my database and then use dreamweaver to pull the images from the database using a recordset. But how do I get to store the images in MySql now that dreamweaver doesn't support BLOB and also how do I make dreamweaver pull the images from that database? PLZ somebody help

    To pull the image from Database on to your page
    1. Open your php page
    2. put your cursor where you want the image to show on the page
    3. insert>image>Select File Name From: Data Sources>select record from recordset> click ok
    4. View in browser
    In Mysyl the image was stored as a "longblob" type with "binary" attributes
    but my system is Dreamweaver CS3.
    Hope this helps. Let me know.

  • Help- how do I make images ready for web gallery??

    Hi,
    I am trying to create a photo gallery of images within Bridge using the Adobe Web Gallery feature. I have the images I want to use in a folder.What steps do I need to take to get the images saved in the correct format and file size? Also, what files sizes do you recommend for a web gallery? I need to make medium to large thumbnails & large images (when clicked). Here's what I am thinking I need in terms of getting this right:
    use Adobe Photoshop/Bridge to create the gallery
    jpg for photos
    gif for solid colors
    file size under 2MB (full image), under 20-30K for (thumbnails), total size of all images under 50K (no more than 50 sec. to download)
    screen size: 984x728
    screen resolution: 72dpi
    If you could help me in any way, shape or form concerning making my images ready for a web gallery that would be most helpful. And if you can refer me to any resources on making a web gallery that'd be awesome. Thank you!
    ashmic19

    Thanks for the link Curt Y that video is really helpful. After looking through some materials I had I figured out how to optimize my images. So I don't need any help anymore. But thanks to all who viewed this and thanks Curt Y for the video!
    ashmic19

  • How do i make images fade into each other

    Hey guys,
    I'm looking to find out how I can make text and/or images fade and appear on my web page. This affect is used on the adobe home page where text fades and other text appears.
    If someone could point me in the right direction that would be great. I think  need to know flash. but any advice would be appreciated. Thanks

    jQuery
    http://www.geeksucks.com/toolbox/23-jquery-fade-in-fade-out-effect.htm
    jQuery Cycle Plug-in might do what you need
    http://malsup.com/jquery/cycle/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • How do I make images tilt to one side in Fireworks?

    I have Fireworks MX --- I know how to import an image, but
    how can I make it tilt slightly? I don't want a full rotate, but
    make it slanted.
    Thanks

    HI, two ways that I know of. The quickest is, with your image
    selected,
    choose the 'Scale' tool from the Tools panel on the left,
    then you can
    rotate the image just by dragging the rotate icon. Or for a
    more precise
    method go to Modify > Transform > Numeric Transform
    > select Rotate from the
    drop down menu and enter the angle amount you require.
    Peter
    "Miss_Angela"
    |I have Fireworks MX --- I know how to import an image, but
    how can I make
    it tilt slightly? I don't want a full rotate, but make it
    slanted.
    |
    | Thanks
    |

  • When I record anything or share my screen on my iMac it only shows my mouse. What am I doing wrong/how do I make it show the rest of the screen too?

    I am trying to record my screen on my iMac for a youtube video. I am using Debut (a screen recording program) and whenever I record the screen, the resulting video is always only showing my mouse movements and not anything else i.e the actual windows etc. This also happens when I share my screen on skype! How do I make the other parts of the screen show up and what am I doing wrong?!
    Thanks!

    Hello Ian,
    No idea really, but are there other computers locally that you can test regular Screen Sharing locally both ways?

  • I am making an iMovie trailer on my iPad 3(updated) and I recorded a few clips on my iPad Camera but they are not being detected on the iMovie Videos section. How can I make them show up?

    I am making an iMovie Trailer on my iPad 3 (updated) and I recorded a few clips using my iPad Camera but they are not being detected on the iMovie Videos scetion. How can I make them appear so I can use them in my trailer?

    Hi Stuck-in-NY,
    If you are looking to transfer your purchases to your computer, you may find the following article helpful:
    Apple Support: Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/HT2519
    Regards,
    - Brenden

Maybe you are looking for

  • Order material

    Hi I have a maintenace order and I need to order some material to carry out this work order, Can you people help me understand how to order a particual material for this work order, I need step by step instruction to complete this task. thanks for yo

  • Slow code insight in JDev 9.0.3.1035

    Hello, sometimes when I invoke code insight in my Jdev it needs up to 30 secs to display. In this time JDeveloper is completely blocked and does not react to any keyboard or mouse input. It doesn't matter if the library is on a network drive or on th

  • Special Prices

    Hi All, I need some assistance with a query to simulate how B1 would choose Prices for a specific customer for a UDF. It would need to check special prices for BP's, period and volume discounts, and if nothing, then return the value to the default pr

  • Creating new Employee in ECC

    Hi, i am new to SAP and new to this group also, Can any one help me how to create new employee(HR) in SAP using the BAPIs, after creation of employee how can i check the new employee details in SAP.Can one give me step by step approach to solve this

  • Airport stopped connecting

    My Macbook works great. It connects to my wifi network everytime. I just turned it on and it will not connect. Every other computer in my house is connected. Is it broke??? or is there a fix? Thanks anyone for your help. Steve