Hey Guys,

I am working on a BlackJack GUI, I have just about everything set up, and now I am working on generating the cards.

I was doing some quick snippet test, to see if I can get it working. But no luck, I wanted to know if I can get some advice on this subject.

Like which Image Class to use.

public void createDealer()
		JPanel dealerPanel = new JPanel();
		dealerPanel.setLayout(new GridLayout());
		Image backCard = new Image();
		JLabel dealerName = new JLabel("Dealer");
		JLabel potAmt = new JLabel("Pot Amount: ");

This is what I am trying to do.

This Card here:

I would call it AH.jpg

I read the Java api, and I just dont know how to add it as an image, and then added it to the dealerPanel(or PlayerPanel), casting an image as a component seemed strange. I dont even know if that method would work.

Any tips towards the correct direction would be great.

7 Years
Discussion Span
Last Post by .11

no edit button?

Anyways an update, I used ImageIcon which worked nicely. Now I wanna have it like this:


Name: Dealer
Pot Amount: $1000

Grouping them together, then the cards will overlap each other with a 25-40px horizontal offsets.

The overlapping cards part I got, but what kind of layout would be good for me to set it up like what I have above.


Check the class javax.swing.ImageIcon with constructor: ImageIcon(String filename) Then you can use a JLabel with constructor: JLabel(Icon image) You might want to consult the above classes' API


Oh crap,

hey javaAddict thanks!

But I decided to go with a text interface at the end, which I finished.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.