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: ");
		
		dealerPanel.add(dealerName);
		dealerPanel.add(potAmt);		
}

This is what I am trying to do.

This Card here:
http://upload.wikimedia.org/wikipedia/commons/d/d3/Poker-sm-221-Ah.png

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.

Recommended Answers

All 3 Replies

no edit button?

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

|||||||||||||||||||
|||||||||||||||||||
|||||||||||||||||||
||||||||AH||||||||
|||||||||||||||||||
|||||||||||||||||||
|||||||||||||||||||

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.