Results 1 to 10 of 10
- 11-05-2008, 11:53 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 19
- Rep Power
- 0
Problem with making/sorting a deck of cards
Thanks for looking at this post!
I am working on making an applet that displays a deck of cards. The program has three buttons: a show/hide toggleButton, a sort button, and a shuffle button. I've got the three buttons working correctly but I can't get the GUI to display the ranks of the cards. (E.g. as 2d...ace of spades, two of diamonds, etc.) The method that we were assigned to "draw" the cards in is the paint(). The pseudocode for how to get the images in the GUI is there but I have no idea what the syntax is going to be. My problem is, how do I get the GUI to display the ranks of the cards? Thanks for any help. :)
Attached is my current program. The paint() is in the CardApplet class.
- 11-06-2008, 12:04 AM #2
Not sure of your terms. Is Ace a rank?how do I get the GUI to display the ranks of the cards
You need a lot more description of the problem.
How are you going to display the cards? One at a time or a full hand of cards? Do you have images for all the different cards or are you going to use text?
You should only use the paint() method to do the drawing of images or text, do the computations outside of paint and call repaint when you want to show something.
- 11-06-2008, 01:19 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 19
- Rep Power
- 0
Yes I do plan on making the computations outside of the paint method and then calling it. As for the ranks, the first character will be the rank of the card such as, " 2, 5, ace, king" and the second character in the rank is the suit. "d for diamond, s spades, c clubs, h hearts." I have images for all of the cards I am going to use. They will be displayed in four rows, one row for each suit. The ranks will be displayed separately. These will just be two characters in the same four rows as the actual images.
- 11-06-2008, 02:48 AM #4
Look at the Graphics drawImage and the drawString methods.
Get the size of all the images and layout on a piece of paper how you want to display to look. Using the size of the images, you can assign positions to where to draw the images. Then figure out where to put the text relative to the images. You will need x,y positions for the location of each image and string to use the draw methods. drawImage has many overloads. If you do a search on the forum you'll find some code examples.
- 11-06-2008, 05:03 PM #5
Member
- Join Date
- Nov 2008
- Posts
- 2
- Rep Power
- 0
I have to do the same problem, but I cant use the drawImage and drawString methods.
- 11-06-2008, 05:39 PM #6
would a LabelProvider work for this? I know I can store images in a folder in my project and the LabelProvider can attach them to menus, buttons, view tabs, etc.
- 11-06-2008, 06:07 PM #7
What does that mean? The assignment says that you can't use those methodsI cant use the drawImage and drawString methods
Or you don't know how to use them. There are many sample codes on this forum. Use search to find them.
- 11-06-2008, 07:19 PM #8
Member
- Join Date
- Nov 2008
- Posts
- 2
- Rep Power
- 0
Here is what I have so far:
I do not know where to go next
- 11-06-2008, 09:19 PM #9
You need to descibe what it is that you want the program to do.
Then show what you've tried to do to make the program do it and ask questions about the problems you are having.
Your code has no comments describing what it is supposed to do. How can anyone make recommendations if there are no specifications on what the code is to do?
It would be easier for people to look at your code if all of it was in a single file, vs 3.
-
Overly general and vague questions of this form are very hard if not impossible to answer and ask too much from the volunteers here. To fix this you need to make some decisions and do some work.I do not know where to go next
1) Do you have problems with your code? if so work on them one at a time and then come back with specific questions and your code.
2) Do you want to extend your currently functioning code? Again if so, try to do this first yourself, then if you run into stumbling blocks come back with code posted in the forum and a specific question.
two resources that may help you help us so that we can better help you include the following:
How to ask Smart Questions
How to create an SSCCE
Much luck!
Similar Threads
-
Sorting JTable (Vectors) Problem
By ramapple in forum AWT / SwingReplies: 6Last Post: 07-06-2009, 11:15 PM -
creating a deck of cards using a linked list
By boomba88 in forum New To JavaReplies: 2Last Post: 09-11-2008, 03:34 PM -
sorting problem...
By mark-mlt in forum New To JavaReplies: 4Last Post: 04-17-2008, 02:15 PM -
sorting problem
By mcal in forum New To JavaReplies: 1Last Post: 02-14-2008, 08:13 AM -
Problem with sorting Table
By sireesha264 in forum Advanced JavaReplies: 0Last Post: 02-08-2008, 02:21 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks