So I'm trying to make an applet that displays images of playing cards. The applet should load a deck of 52 playing card images (the folder is called "images"). The applet should shuffle the deck (using a random number generator) and display the first 10 cards of the shuffled deck. I then have to display the cards in two rows of five cards each.
With this code I have about 100 errors and I'm not sure what I'm doing wrong:
"In this assignment you will use an applet to display images of playing cards. The applet should load a deck of 52 playing card images from the "images" folder that you downloaded. The applet should shuffle the deck (use a random number generator) and display the first 10 cards of the shuffled deck. Display the cards in two rows of five cards each."
That is my goal for this assignment. I've got my code compiling and I will post it below and I've got an html page but when I try to open it I get an error
import java.applet.Applet; import java.awt.Graphics; import java.awt.Image; import java.util.Random; public class Assignment12 extends Applet { Image card1; Image card2;
So I'm trying to make an applet that displays images of cards. The applet has a deck of 52 playing card images. It should shuffle the deck with a random number generator and display the first 10 cards of the shuffled deck.
With this code I have about 100 errors and I'm not sure what I'm doing wrong: I know I have to use arrays in order to ultimately display the images, but do I have to create Image objects for the Image [] cards array? I am getting many "class, interface, enum expected" errors as well as others.
import java.util.Random; import java.awt.Image; import java.applet.Applet; import java.awt.Graphics; public class unit12 extends Applet {
1 - I don't understand why I'm getting an empty stack error when calling the removecard method in my Table class line 13?
2 - I am trying to use a constructor to populate my deck of cards instead of a method when creating my theDeck object in my Table class line 11 but I get the following error:
java.lang.StackOverflowError at java.util.Vector.<init>(Unknown Source) at java.util.Vector.<init>(Unknown Source) at java.util.Stack.<init>(Unknown Source) at Deck.<init>(Deck.java:7) at Deck.<init>(Deck.java:34)
I have a super class and an inherited class. What it is supposed to do is display random images in one applet. The images dont match the words and images dont match the wording. What am I doing wrong? Probably a few errors.
Super Class:
import java.awt.Color;; public class Dukes { private Color noseColor = Color.red; // default Dukes have red noses private String action = "../../images/duke/dukeWave.gif"; //default Dukes are friendly private String whatDoing = "Give me something to do"; private String message= ""; public Dukes() { int rint = (int)(Math.random() * 3); // randomly generates a 0, 1, or 2 if (rint == 0)
Basically I started writing my code in one class, then I split it up into a Card class and a DeckOfCards class and I now need to figure out how to get it all to work together. I get a little confused with calling methods sometimes, especially when separate classes are in play. I think I just need a method to deal out . Besides getting it all working together correctly. I'm also having trouble creating the method to deal out five cards that also tells how many cards are left in the deck and I believe I need a toString method but I honestly do not know how to go about that.
Design and implement a class called Card that represents a standard playing card. Each card has a suit and a face value. Then create a class called DeckOfCards that stores 52 objects of the Card class. Include methods to shuffle the deck, deal a card and report the number of cards left in the deck. The shuffle methods should assume a full deck. Create a driver class (CardsGame) with a main method that deals five cards from the shuffled deck, printing each card as it is dealt. Make sure to write the appropriate constructors, getters, setters, toString and other methods as required for both classes.
The main class, CardsGame Class
import java.util.Scanner; public class CardsGame { public static void main (String [] args) { DeckOfCards deck = new DeckOfCards(); //call shuffle deck.shuffle();
I have an assignment for my summer class. Basically I started writing my code in one class, then I split it up into a Card class and a DeckOfCards class and I now need to figure out how to get it all to work together. I get a little confused with calling methods sometimes, especially when separate classes are in play. I think I just need a method to deal out . Besides getting it all working together correctly. I'm also having trouble creating the method to deal out five cards that also tells how many cards are left in the deck and I believe I need a toString method but I honestly do not know how to go about that. FYI, I think the prof would rather arrays then enums since we're dealing with arrays right now hence the array for the 52 card deck.
Here are the directions...
Design and implement a class called Card that represents a standard playing card. Each card has a suit and a face value. Then create a class called DeckOfCards that stores 52 objects of the Card class. Include methods to shuffle the deck, deal a card and report the number of cards left in the deck. The shuffle methods should assume a full deck. Create a driver class (CardsGame) with a main method that deals five cards from the shuffled deck, printing each card as it is dealt. Make sure to write the appropriate constructors, getters, setters, toString and other methods as required for both classes.
The main class, CardsGame Class
Java Code:
import java.util.Scanner; public class CardsGame { public static void main (String [] args) { DeckOfCards deck = new DeckOfCards(); //call shuffle deck.shuffle();
The code below is just the GUI for a slot machine. Currently when play is clicked it displays the random number, I'm trying to make it so each random number displays an image in the GUI instead. For example if the random numbers were 2,2,3 it would display Cherry, Cherry, Bells. I started changing field1 to the image but realised I was on the wrong track as it would just display the same image not one allocated to a number. I've left in what I started doing.
how to do it?
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SlotMachineGUI { JPanel mainPanel; SlotMachine slotEngine;
I want to be able to get an image online and display on my JPanel but for some reason my image wont load and just shows a blank square, but when I try to load an image from my hard drive it works just fine.
I'm doing a project in which I must display prices of computer accessories in a Scroll Pane viewer. The if statements are all checkboxes. I am completely lost with how to print to the viewer if a checkbox is selected. Furthermore, I am also lost with how to add up all of the checkboxes.
private void USBCheckActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: double area = 0; double computerprice = 500.0; if (printerCheck.isSelected()){ double printer = 100.0;
import java.awt.Graphics; import javax.swing.JApplet; public class Exercise23_7 extends JApplet { // method paint to paint a checker board pattern public void paint( Graphics g )
Implement an applet that display historical facts. The applet will include facts from october 28 to december 4th to test the applet.
What is the best thing to add text in my GUI - JLabel, JTextArea? I am trying to display different words on my csFacts. Once a user click button yesterday and button tomorrow?
public class Facts extends JFrame implements ActionListener{ private JButton button1,button2; private JPanel panel; private JLabel label; TextField ri = new TextField(50); private void createGUI(){ setDefaultCloseOperation(EXIT_ON_CLOSE);
Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:205) at GUI.<init>(GUI.java:26) at Apples.main(Apples.java:7)
i think the problem is to do with my images not being recognised. I put them in my source in User>...>workspace>src which is correct as far as i know. From what i know the images should show up if i look at my src file in eclipse but they dont. I tried changing the file type from .png to .jpg but it makes no difference.
I'm not getting any errors, just i can't seem to stop the music from playing after clicking the jbutton "Sound On" / "Sound Off" again. I've tried a few methods but it just isn't working for me.
I'm not getting any errors, just i can't seem to stop the music from playing after clicking the jbutton "Sound On" / "Sound Off" again. I've tried a few methods but it just isn't working for me.
I'm building app using Javafx Webview, but I have problems with running any Youtube video in Webview. The strange thing is that rarely it plays ok but more often it shows info "An error occurred, please try again later".
I tried to figure it out, so I made simple app using Youtube iframe API and firebug lite to show where is the problem:
Here is source of Main.java
Here is source of video.html
When I run it on my PC I see the result as below:
Error state 5 means "The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.".
When I run this video.html file in firefox, chrome, or internal eclipse browser, everything is ok and always work.
I use JRE and JDK 1.8.20 but tried also with older versions, Windows 7 64 bit. I've also installed DivX - did not work. I tried on different PC (also win7 64 bit) and asked 2 people with similar config to run this - and it is not working. As far as I know there is everything ok on Mac.
I was testing my JavaFX2.2.7 based media player code in a current Java 6 application when I discovered that HTTP Live Streaming does not seem to work. I can play a local file of the supported format (Sintel trailor mp4 h264) but when I try and use an HTTP Live Stream instead, nothing plays. (for example [URL] ). I end up with a blank player, and no exceptions or errors.
private static final String MEDIA_URL = "http://download.oracle.com/otndocs/products/javafx/JavaRap/prog_index.m3u8"; Media media = new Media(MEDIA_URL); MediaException ex = media.getError(); if (ex != null){ System.out.println("Media Error" + ex.getMessage()); } else{ System.out.println("No Media Error"); }
Program console output: "No Media Error"
I thought it was something wrong with my player code, so as a last resort, I went to JavaFX 2 - Ensemble and copied the source and put it directly into my application and ran it... Unfortunately the same result occurs. The player runs, but simply shows a blank video window. The controls are available, but no video plays.
Based on the Release notes for Java 2.2.7 I was under the impression that HLS was supported. Am I incorrect? I cannot upgrade to Java 7 as I am firmly stuck with Java 1.6.0.32 due to project constraints.
Assuming we have an array that is int[] cardDeck = new int[52] and each card is given a value with the following method; this deck does not include Jokers. Note: 11, 12, and 13 and used to represent Jacks, Queens, and Kings respectively, and 1 is used to represent Aces.
Java Code:
public static void loadDeck(int[] cardDeck) { for(int i = 0; i < cardDeck.length; i++) { if(i+1 > 39) cardDeck[i] = i+1-39; else if(i+1 > 26)
I have red underlines under "Card" and "cards" in my Deck class and "deal" in my driver and i don't know how to fix them to get it to properly run.
Card Class:
Java Code:
public class Card { public final static int ACE = 1; // note: or use enumerated types public final static int TWO = 2; public final static int THREE = 3; public final static int FOUR = 4; public final static int FIVE = 5; public final static int SIX = 6; public final static int SEVEN = 7;
i'm trying to make a random card shuffler but the output would sometimes have same value multiple times. For example it might print out A5 at the fifth index then print out A5 again as the 32 index.
I curious for tips for moving forward within my current code for my counting cards GUI interface. I need two labels one for the card deck, and the other for the randomized card face. When the card face shows, in the count value text field the value of the card is added. For each card this is to happen through until the whole deck. There is also a card count text field to count how many cards have been dealt out. Now with that being said, I am being held back by getting the two labels to show in my GUI, the buttons show, but I need getting the cards and its value to show and initialize, with the card count in the card count text field.
import java.lang.Math; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class CardsGui extends JFrame
I am trying to make a program that will make a deck of 52 cards, but not shuffle it. I can't get rid of the errors in the code that I have so far.
Java Code:
public class Deck { private Card[] deck; private int cardsUsed; public Deck() { deck = new Card[52]; int cardCt = 0; for ( int suit = 0; suit <= 3; suit++ ) { for ( int value = 1; value <= 13; value++ ) { deck[cardCt] = new Card(value,suit); cardCt++; } } cardsUsed = 0; } } mh_sh_highlight_all('java');
I am getting red squiggly lines on lines:
#3 under "Card" #8 under "deck" and "Card" #12 under "deck" and "Card"
I have tried to add a scroll bar line 28 - 31 and can't figure out why its not working. Its not even showing the scroll bar!
public class TheFrame extends JFrame { private static ThePanel canvas; private String deckImagesToUse; /** * The constructor creates a Frame ready to display the cards */ public TheFrame(String cardImgFile) {