0

I am trying to do a poker hand simulator. I am using Netbeans, and by the means of its GUI editor I created a JFrame in which I added the JPG of the poker table. After doing this, is it possible to dynamically add JPGs according to the hand that the player has over the poker table JPG? Is it possible to add a JPG over another? If so, how can I achieve this in NetBeans?

What I am planning to do is display all the players at the table, together with their stack and name and display their action. All this will be done with cards face up. The simulator will calculate some odds and will output some hand details in a pdf.

I want to mention that this is a homework project.

Mike
  • 47,263
  • 29
  • 113
  • 177
  • Sure, it's quite possible. How about giving us a small example of what you already have? Code wise? Then we could show you where to modify what to enable to loading of more images. – Ewald May 18 '12 at 08:00
  • 1) *"I created a Frame"* If you mean `JFrame`, please spell it correctly. If you mean `java.awt.Frame` then don't use AWT. 2) *"player has OVER THE POKER TABLE JPG"* There is no need to SHOUT at us. – Andrew Thompson May 18 '12 at 08:04
  • I do not really have anything yet, all I have done, was done in the GUI editor of the NetBeans, which automatically generates code. What I need is a starting point - should I add jLabels to the table and modify them according to the hand information ? – Mihai Andrei Rustiuc May 18 '12 at 08:04
  • I am not shouting man, I just want to make things clear so I am not misunderstood. There's no need to be arogant just because you know more - I am here to learn and try to blend into this community. That's why it is a community, to help each other, right? – Mihai Andrei Rustiuc May 18 '12 at 08:06
  • *"try to blend into this community"* DO YOU DO THAT BY COMING INTO A ROOM AND SHOUTING? – Andrew Thompson May 18 '12 at 08:10
  • 1
    If that is how you understand things, after they are explained to you and the reasons behind them are clearly stated, it only proves how narrow-minded you are. In order to raise the white flag, I will edit my post so that you won't be offended by it. – Mihai Andrei Rustiuc May 18 '12 at 08:13
  • *"If that is how you understand things, after they are explained to you and the reasons behind them are clearly stated, it only proves how narrow-minded you are."* Wow. Change 'narrow-minded' to 'narrow-minded & self infatuated' & that could become a perfect "back at ya'". – Andrew Thompson May 18 '12 at 08:16

1 Answers1

0

What you are after should be possible. I would recommend you take a look at the Layouts offered by the Swing Framework and once you will find what you need you can take a look here to see how you can implement the layout of your choice.

EDIT: If you are satisfied with how is your application is laid out, you should take a look at the ImageIO to see how you can load JPG images on the fly and add them to your JPanels. Usually one would use the JLabel(Icon image) constructor to add images to JPanels but there are other methods.

npinti
  • 51,780
  • 5
  • 72
  • 96
  • I am familiar with the Layouts provided by Swing. However, I found that using the NetBeans GUI editor is both easier and suits my needs better than using those. – Mihai Andrei Rustiuc May 18 '12 at 08:08
  • @MihaiAndreiRustiuc: I have modified my answer – npinti May 18 '12 at 08:22
  • that is what I was thinking about - using jLabels. However, the poker table jpg is also a jLabel. Can I add a jLabel inside another by using the NetBeans GUI Editor ? – Mihai Andrei Rustiuc May 18 '12 at 08:26
  • @MihaiAndreiRustiuc: I do not think you can add a JLabel within a JLabel. But what you could do is to put one on top of another. There should a layout which does this, being the [`CardLayout`][1] (http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html) so you should take a look at that. – npinti May 18 '12 at 08:34