Results 1 to 6 of 6

Thread: swing image

  1. #1
    felito is offline Member
    Join Date
    Nov 2010
    Posts
    48
    Rep Power
    0

    Default swing image

    hi guys, i have a problem with my program

    i don't have any output error, but my image isn't display in program

    Java Code:
    package game;
    import java.util.Random;
    import javax.swing.ImageIcon;
    
    public class deck {
    
    	private Card deckOfCards[];
    	private final int number_cards = 52;
    	private Random various;
    	private int currentCard;
    	private int actualCard;
    	public ImageIcon cardImage;
    
    
    	public deck() { int value[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11 };
    any help please?
    Last edited by felito; 01-26-2011 at 02:43 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Try creating a much smaller program whose goal is only to show a single image. Let's reduce and simplify the problem as much as possible to helps us solve it.

  3. #3
    felito is offline Member
    Join Date
    Nov 2010
    Posts
    48
    Rep Power
    0

    Default

    solved,

    Java Code:
    	public void setImage(ImageIcon Image) {
    		this.cardImage = Image;
    	}
    
    	public ImageIcon getImage() {
    		return deckOfCards[actualCard].Image;
    	}
    
    
    
    panel2.add(new JLabel(myDeckOfCards.getImage()));
    thanks

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    ..... congrats!

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    But please next time, do not cross-post the question without notifying all cross-posts. Otherwise you're not being fair to the volunteers in either forum.

  6. #6
    felito is offline Member
    Join Date
    Nov 2010
    Posts
    48
    Rep Power
    0

Similar Threads

  1. Problem with displaying an image in Java Swing
    By BackInSoftware in forum Advanced Java
    Replies: 10
    Last Post: 01-11-2011, 06:56 PM
  2. scanned image save by swing dialog box
    By gaurav17may in forum AWT / Swing
    Replies: 8
    Last Post: 07-20-2010, 12:48 PM
  3. Best Swing widget to draw and edit image
    By bikashg in forum New To Java
    Replies: 1
    Last Post: 04-29-2010, 05:21 PM
  4. how to set an image to a frame in swing?
    By vrk in forum AWT / Swing
    Replies: 2
    Last Post: 10-20-2009, 02:52 PM
  5. image link in swing
    By sri_java in forum SWT / JFace
    Replies: 0
    Last Post: 04-10-2009, 05:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •