# Java Projekt Black Jack



## jockijo (16. Mai 2010)

Hallo zusammen,
wir sollen ein Java Projekt zum Thema Black Jack machen. Bisher lief auch alles gut, aber wenn ich das Programm starte, werden die Bilder nicht angezeigt (Karten) und das Fenster wird zu klein geöffnet. Ebenso ist auch die farbliche Hintergrundsfläche zu klein. Die Berechnungen und die Buttons gehen jedoch alle einwandfrei. Hier mal die Quellcodes meiner Klassen (hab Kommentare immer hinzugefügt).

Im Anhang hab ich noch ein Bild eingefügt, wie das Spiel derzeit aussieht und wie es breiter aussehen sollte.
Hoffe jemand kann mir weiterhelfen ???:L

Klasse CKarte

```
package paketBJ;

import java.awt.*;
import java.util.*;


public class CKarte{

	  Image bild;
	  int wert;
	  
	  public CKarte(Image bild, int wert) {
	    this.bild = bild;
	    this.wert = wert;
	  }
	    
	  public Image getBild() {
	    return bild;
	  }
	  
	  public int getWert() {
	    return wert;
	  }
	  
	  public void setWert(int wert) {
	    this.wert = wert;
	  }
	}
```


Klasse CDeck

```
package paketBJ;

import java.util.*;
import java.awt.Image;
import java.applet.*;
import java.net.*;
import java.io.*;


public class CDeck {
	
	int anzahlDecks = 6;
	int anzahlKarten = 52 * anzahlDecks;
	Vector meinDeck = new Vector();

	public CDeck(CBlackJack myApplet,Image[] kartenBilder) {
		int i, j, k;
		
		//Neues Deck anlegen
		for (i=0; i<anzahlDecks; i++)
		{
			for (j=0; j<52; j++) {
				for (k=2; k<11; k++) {
					meinDeck.add(new CKarte(kartenBilder[j],k));
					j++;
				}
				meinDeck.add(new CKarte(kartenBilder[j],10));
				meinDeck.add(new CKarte(kartenBilder[j+1],10));
				meinDeck.add(new CKarte(kartenBilder[j+2],10));
				meinDeck.add(new CKarte(kartenBilder[j+3],11));
				j=j+3;		
			}
		}
		//Kartendeck mischen
		mischen();
	}

	public void mischen(){
		Collections.shuffle(meinDeck);
	}

  
	public CKarte geben() {		
		return (CKarte) meinDeck.remove(0);
	}

	public CKarte getKarte(int i) {
		return (CKarte) meinDeck.elementAt(i);
	}

	public int getRestAnzahl() {
		return meinDeck.size();
	}



}
```


Klasse CHand

```
package paketBJ;
import java.util.*;


public class CHand {
	
	private Vector meineKarten = new Vector();
	private int summe;
	int ass = 0;

	//Konstruktor für eine Kartenhand
	public void Hand(){
		summe=0;
		ass=0;
	}
	
	public CKarte getKarten(int i){
		return (CKarte) meineKarten.elementAt(i);
	}
	
	//Karte zu Hand hinzufügen
	public void addKarte(CKarte k) {
		meineKarten.add(k);
		summe=summe+k.getWert();
		
		if(k.getWert() == 11)
			//Wenn die Karte ein Ass ist, anzahl der Asse merken
			ass++;
		if(summe > 21){
			//Wenn Summe > 21, Assen als 1 zählen
			for(int i=0; i<ass && summe>21; i++) {
				summe=summe-10;
				ass--;
			}
		}
	}
	
	public boolean blackJack() {
		if (summe == 21 && meineKarten.size() == 2) {
			return true;
		}
		else {
			return false;
		}
	}
	  
	public int getKartenAnzahl(){
		return meineKarten.size();
	}	  
	  
	public int getSumme() {
		return summe;
	}
	


}
```



Klasse CBlackJack


```
package paketBJ;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;




/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit [url=http://www.cloudgarden.com]Cloud Garden (Java Resources)[/url] for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class CBlackJack extends Applet implements ActionListener,Runnable{
	
private CDeck deck;
	
	private CHand spielerHand;
	private CHand geberHand;

	public Button btnZiehen=new Button("Ziehen");
	public Button btnHalten=new Button("Halten");
	public Button btnNächsteRunde=new Button("Nächste Runde");
	public Button btnNeuesSpiel=new Button("Spiel Neustart");	
	public Button btnEinzahlen=new Button("€ 50 einzahlen");
	
	Image offIm=null;
	Graphics offGraphics=null;
	
	Image[] kartenBilder = new Image[52];
	private int aktKarteLaden = 0;	
	
	int breite, höhe;
	int kartenBreite = -1;
	int anpassen = -1;	
	
	private int spiel = 0;					//Anzahl der Spiele
	private int runde = 1;					//Anzahl der Runden	
	private String message1;				//String für Meldungen
	private String message2;				//String für Meldungen
	private double geldbetrag = 50.00;		//Geldbetrag der dem Spieler zur Verfügung steht
	private double gesamtbetrag = 50.00;	//Gesamter eingesetzter Betrag des Spielers
	private double gewinnverlust = 0;		//Aktueller Gewinn/Verlust des Spielers
	private double geldeinsatz = 5.00;		//Einsatz pro Runde
	private double gewinnBlackJack = 1.5;	//Gewinnverhältnis bei einem Black Jack
 
	public void init() {	
		Thread kartenLaden = new Thread(this);
		kartenLaden.start();
	}
	
	public void run(){
		MediaTracker mt=new MediaTracker(this);
	
		for(aktKarteLaden=0; aktKarteLaden < 52; aktKarteLaden++){
		  
			kartenBilder[aktKarteLaden] = getImage(getCodeBase(),
				"Karten/" + (aktKarteLaden+1) + ".gif");
			mt.addImage(kartenBilder[aktKarteLaden],0);
			repaint();
		}		
		//Neues Deck anlegen
		deck = new CDeck(this,kartenBilder);
		
		//Breite der Kartenbilder feststellen
		kartenBreite = deck.getKarte(0).getBild().getWidth(this);

		btnZiehen.addActionListener(this);
		btnHalten.addActionListener(this);
		btnNächsteRunde.addActionListener(this);
		btnNeuesSpiel.addActionListener(this);
		btnEinzahlen.addActionListener(this);
		
		btnZiehen.setEnabled(false);
		btnHalten.setEnabled(false);
		btnNächsteRunde.setEnabled(false);
		btnEinzahlen.setEnabled(false);

		//Breite und Höhe des Applets sichern
		breite  = getSize().width;
		höhe = getSize().height;
		message1 = "";
		message2 = "";

		this.add(btnZiehen);
		this.add(btnHalten);
		this.add(btnNächsteRunde);	
		this.add(btnEinzahlen);	
		this.add(btnNeuesSpiel); 

		//Neue Kartenhände anlegen
		spielerHand = new CHand();
		geberHand = new CHand();
		
		this.validate();		
		repaint();
	}
	
	public void actionPerformed(ActionEvent ae) {
 
		if(ae.getSource() == btnNeuesSpiel) {
			neuesSpiel();
		}
		else if (ae.getSource() == btnZiehen) {
			ziehen();
		}
		else if (ae.getSource() == btnHalten) {
			halten();
		}
		else if (ae.getSource() == btnNächsteRunde)	{
			nächsteRunde();
		}
		else if (ae.getSource() == btnEinzahlen) {
			einzahlen();
		}
		   
		repaint();
	}
  
	public void paint(Graphics g) {
		if(offGraphics==null){
			offIm=createImage(getSize().width,getSize().height);
			offGraphics=offIm.getGraphics();
		}
		
			Image aktKarte;

			if(kartenBreite == -1)
				kartenBreite = deck.getKarte(0).getBild().getWidth(this);
			
			if(anpassen == -1)
				anpassen = (breite - (kartenBreite * 2) - 4) / 4;

			//Hintergrundfarbe setzen
			offGraphics.setColor(new Color(20,100,20));
			offGraphics.fillRect(0,0,breite,höhe);
			offGraphics.setColor(Color.white);
			offGraphics.drawString("Spieler: "+spielerHand.getSumme(),anpassen,40);
			offGraphics.drawString("Geber: "+geberHand.getSumme(),(breite/2) + anpassen,40);
			offGraphics.drawString(message1,5,höhe - 94);			
			if(spiel > 0)
			{
				offGraphics.drawString("Restliche Karten: "+deck.getRestAnzahl(),5,höhe - 66);			
				offGraphics.drawString("Spiel "+spiel+" Runde "+runde,5,höhe - 38);
			}
			offGraphics.drawString(message2,5,höhe-10);
			//Anzeigen der Kartenhand des Spielers
			for(int i=0;i<spielerHand.getKartenAnzahl();i++){
				offGraphics.drawImage(spielerHand.getKarten(i).getBild(), anpassen, 70+(20*(i-1)), this);//neu
			}
			//Anzeigen der Kartenhand des Gebers
			for(int i=0;i<geberHand.getKartenAnzahl();i++){
				offGraphics.drawImage(geberHand.getKarten(i).getBild(), (breite/2 ) + anpassen, 70+(20*(i-1)), this);
			}		
		g.drawImage(offIm,0,0,this);
 
	}

public void neuesSpiel(){
		//Button für Ziehen enablen
		btnZiehen.setEnabled(true);
		//Buttons für nächste Rundek, Neues Spiel und Halten disablen
		btnHalten.setEnabled(false);
		btnNeuesSpiel.setEnabled(false);
		btnNächsteRunde.setEnabled(false);

		//Vor jedem neuen Spiel werden die Karten gemischt
		deck = new CDeck(this,kartenBilder);

		//Neue Kartenhände anlegen
		spielerHand = new CHand();
		geberHand = new CHand();
		
		//Geber und Spieler bekommen je eine Karte
		spielerHand.addKarte(deck.geben());
		geberHand.addKarte(deck.geben());
		
		//Spieler macht Einsatz
		geldbetrag = 50 - geldeinsatz;
		gesamtbetrag = 50;
		message1 = "Ihr Geldbetrag ist € "+geldbetrag;
		message2 = "";
		
		runde = 1;
		spiel++;
		
		if (geldbetrag == 0) {
			btnEinzahlen.setEnabled(true);
			btnNeuesSpiel.setEnabled(false);
		}
	}
	
	public void nächsteRunde(){
		//Button für Ziehenenablen		
		btnZiehen.setEnabled(true);
		//Buttons für nächste Runde, Neues Spiel und Halten disablen
		btnHalten.setEnabled(false);
		btnNeuesSpiel.setEnabled(false);
		btnNächsteRunde.setEnabled(false);

		//Neue Kartenhände anlegen
		spielerHand = new CHand();
		geberHand = new CHand();

		//Geber und Spieler bekommen je eine Karte
		spielerHand.addKarte(deck.geben());
		geberHand.addKarte(deck.geben());
	
		runde++;
		
		//Spieler macht Einsatz
		geldbetrag = geldbetrag - geldeinsatz;
		message1 = "Ihr Geldbetrag ist € "+geldbetrag;
	}
 
	public void ziehen(){

		btnHalten.setEnabled(true);

		spielerHand.addKarte(deck.geben());
		//Wenn der Spieler über 21 hat, dann hat er verloren
		if(spielerHand.getSumme() > 21){
			message1 = "Sie haben verloren! Sie haben noch € "+geldbetrag;
			//Buttons für Ziehen und Halten disablen
			btnZiehen.setEnabled(false);
			btnHalten.setEnabled(false);
			//Button für nächste Runde enablen, wenn Geldbetrag > 0
			if (geldbetrag > 0) {
				btnNächsteRunde.setEnabled(true);
				btnNeuesSpiel.setEnabled(true);
			}else {
				btnEinzahlen.setEnabled(true);
				btnNeuesSpiel.setEnabled(false);
			}
			//Wenn im Deck 10 Karten oder weniger sind, werden alle Karten neu gemischt
			if (deck.getRestAnzahl() < 11) {
				deck = new CDeck(this,kartenBilder);
			}
			//Gesamter Gewinn/Verlust berechnen
			message2 = gewinnVerlust();
		}		
	}

	public void halten(){

		//Geber muss nehmen, solange seine Summer unter 17 ist
		while(geberHand.getSumme() < 17){
			geberHand.addKarte(deck.geben());
		}
		//Wenn der geber mehr Punkte hat, hat der Spieler verloren
		if(geberHand.getSumme() <= 21 && spielerHand.getSumme() < geberHand.getSumme())
		{
			message1 = "Sie haben verloren! Sie haben noch € "+geldbetrag;
		}
		//wenn der Spieler einen Black Jack hat und der Geber nicht, dann hat der Spieler gewonnen
		else if (spielerHand.blackJack() && geberHand.blackJack() == false) {
			geldbetrag = geldbetrag + geldeinsatz + gewinnBlackJack*geldeinsatz;
			message1 = "Black Jack! Sie haben € "+geldeinsatz*gewinnBlackJack+" gewonnen! Sie haben jetzt € "+geldbetrag;
		}
		//Bei Gleichstand bekommt der Spieler seinen Einsatz zurück
		else if (spielerHand.getSumme() == geberHand.getSumme())
		{
			//Hat bei Gleichstand der Geber einen Black Jack, hat der Spieler verloren
			if (geberHand.blackJack() && spielerHand.blackJack() == false) {
				message1 = "Sie haben verloren! Der Geber hat Black Jack! Sie haben noch € "+geldbetrag; 
			}
			else {
				geldbetrag = geldbetrag + geldeinsatz;
				message1 = "Unentschieden! Sie haben noch € "+geldbetrag;
			}
		}
		//Wenn der Spieler mehr Punkte hat, dann hat er gewonnen
		else {
			geldbetrag = geldbetrag + 2*geldeinsatz;
			message1 = "Sie haben € "+geldeinsatz+" gewonnen! Sie haben jetzt € "+geldbetrag;
		}

		btnZiehen.setEnabled(false);
		btnHalten.setEnabled(false);
		
		if (geldbetrag > 0) {
			btnNeuesSpiel.setEnabled(true);
			btnNächsteRunde.setEnabled(true);
		}
		else {
			btnEinzahlen.setEnabled(true);
			btnNeuesSpiel.setEnabled(false);
		}
		//Wenn im Deck 10 Karten oder weniger sind, werden alle Karten neu gemischt
		if (deck.getRestAnzahl() < 11) {
			deck = new CDeck(this,kartenBilder);
		}
		
		//Gesamter Gewinn/Verlust berechnen
		message2 = gewinnVerlust();
	}
	
	public void einzahlen() {
		geldbetrag = geldbetrag + 50;
		gesamtbetrag = gesamtbetrag + 50;
		message1 = "Sie haben noch € "+geldbetrag;
		btnNächsteRunde.setEnabled(true);
		btnNeuesSpiel.setEnabled(true);
		btnEinzahlen.setEnabled(false);
	}
	
	public String gewinnVerlust() {
		//Gesamter Gewinn/Verlust berechnen
		gewinnverlust = geldbetrag - gesamtbetrag;
		if (gewinnverlust < 0) {
			return "Sie haben bist jetzt € "+(-1)*gewinnverlust+" verloren!";
		}
		else {
			return "Sie haben bist jetzt € "+gewinnverlust+" gewonnen!";
		}
	}
	
	private void initGUI() {
		try {
			{
				this.setPreferredSize(new java.awt.Dimension(491, 335));
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

}
```


----------



## Tomate_Salat (16. Mai 2010)

Die Exception die er schmeist ignorierst du wohl erfolgreich und die Datei [c]GuiAuswahl.java[/c] wird als fehlerhaft angezeigt, schau dir mal diese an, solltest du den Fehler nicht beheben können:

-> poste die Exception + poste GuiAuswahl

MFG

Tomate_Salat


----------



## jockijo (16. Mai 2010)

hallo, 
danke für deine schnelle antwort 
leider bin ich noch recht am anfang meiner programmierkarriere (machen das gerade am wirtschaftsgymnasium). einen großteil des quellcodes haben wir daher vorgefertigt bekommen und manche sachen sollten wir laut lehrer einfach auswendig lernen.

daher weis ich jetzt nicht genau was du mit Exception + GuiAuswahl meinst. wäre echt nett, wenn du mir das sagen könntest, bin nämlich auch bestrebt etwas zu lernen 

danke


----------



## Tomate_Salat (16. Mai 2010)

Java ist auch eine Insel 8 | Exceptions

mit GUIAuswahl meine ich die Datei GUIAuswahl.java. Wenn du auf deinen ersten screenshot schaust, siehst du ganz unten eine Konsole mit viel rotem Text: alles markieren -> kopieren -> hier posten.

MFG

Tomate_Salat


----------



## jockijo (16. Mai 2010)

Ah ok, danke. Hier der Text:

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:137)
	at sun.awt.RepaintArea.paintComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:137)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:137)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:146)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:146)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


----------



## Tomate_Salat (16. Mai 2010)

Versuche mal in CBlackJack in der Zeile 136:
[java=136]
if(kartenBreite == -1)
          kartenBreite = deck.getKarte(0).getBild().getWidth(this);
[/code]
folgendes:
[java=136]
if(kartenBreite == -1)
          kartenBreite = deck.getKarte(0).getBild().getWidth(null);
[/code]

sollte das nicht helfen, mache mal folgendes an der gleichen stelle:
[java=136]
if(kartenBreite == -1)
{
       //kartenBreite = deck.getKarte(0).getBild().getWidth(this);
       System.out.println("GetKarte: " + deck.getKarte(0) );
       System.out.println("GetBild: " + deck.getKarte(0).getBild() );
}
[/code]

Und poste dann, was er unten in der Konsole anzeigt (dort wo du auch die Exception gefunden hast ;-)

MFG

Tomate_Salat


----------



## jockijo (16. Mai 2010)

leider funktioniert das nicht - hab mal 

if(kartenBreite == -1)
{
       //kartenBreite = deck.getKarte(0).getBild().getWidth(this);
       System.out.println("GetKarte: " + deck.getKarte(0) );
       System.out.println("GetBild: " + deck.getKarte(0).getBild() );
}

eingegeben, wie du gesagt hattest und in der konsole kam dann folgendes:
GetKarte: paketBJ.CKarte@12d03f9
GetBild: sun.awt.image.ToolkitImage@5ffb18


----------



## Tomate_Salat (16. Mai 2010)

```
kartenBreite = deck.getKarte(0).getBild().getWidth(null);
```

Lass das mal drin, deine CBlackJack implementiert keinen ImageObserver, weswegen du kein [c]this[/c] hier verwenden kannst.

*Anmerkung:* du kannst aber mal danach schreiben: 

```
System.out.println("Kartenbreite: " + kartenBreite);
```
um zu sehen, ob die Breite auch korrekt ist.




Ok nächste (NullPointer)Exception wird in zeile 146(CBlackJack.java) geworfen:
[java=146]
offGraphics.drawString("Spieler: "+spielerHand.getSumme(),anpassen,40);
[/code]

schreib mal hier bitte hin:
[java=146]
//offGraphics.drawString("Spieler: "+spielerHand.getSumme(),anpassen,40);
System.out.println("Spielerhand: " + spielerHand);
[/code]
und poste, was er ausgibt


----------



## jockijo (16. Mai 2010)

wenn ich
//offGraphics.drawString("Spieler: "+spielerHand.getSumme(),anpassen,40);
System.out.println("Spielerhand: " + spielerHand);

eingebe kommt folgendes (wenn ich 
offGraphics.drawString("Spieler: "+spielerHand.getSumme(),anpassen,40);
nicht ersetze):
Spielerhand: paketBJ.CHand@5ffb18



bei
System.out.println("Kartenbreite: " + kartenBreite);

kommt:
Kartenbreite: -1


----------



## Tomate_Salat (16. Mai 2010)

Ok, mit Kartenbreite haben wir dann wohl noch ein Problem, das hängen wir aber mal hintendran, erstmal den anderen Nullpointer wegbekomen:

was bringt den (immernoch CBlackJack.java)

```
public void paint(Graphics g) {
        if(offGraphics==null){
            offIm=createImage(getSize().width,getSize().height);
            offGraphics=offIm.getGraphics();
        }
        System.out.println("offIm: " + offIm);
        System.out.println("offGraphics: " + offGraphics);
```


----------



## jockijo (16. Mai 2010)

dann kommt folgendes:

offIm: BufferedImage@5ffb18: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
offIm: BufferedImage@5ffb18: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=255,g=255,b=255]]


----------



## Tomate_Salat (16. Mai 2010)

schmeist er beim Ausführen überhaupt noch eine Exception?


----------



## jockijo (16. Mai 2010)

ja - ich poste dir mal den ganzen konsolenausdruck:

offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at sun.awt.RepaintArea.paintComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=0,g=0,b=0]]
offIm: BufferedImage@89fbe3: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 200 height = 200 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
offGraphics: sun.java2d.SunGraphics2D[font=java.awt.Font[family=Dialog,name=Dialog,style=plain,size=12],color=java.awt.Color[r=255,g=255,b=255]]


----------



## Tomate_Salat (16. Mai 2010)

poste nochmal CBlackJack.java sonst kann ich nur raten was in zeile 142 nach den änderungen steht


----------



## jockijo (16. Mai 2010)

ok - bin nicht sicher ob das das richtige ist (ist das rote, wo immer CBlackJack.java:142 steht)--- oder meintest du das mit der schwarzen schrift?:

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at sun.awt.RepaintArea.paintComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)




Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)




Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)




Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)



Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
	at paketBJ.CBlackJack.paint(CBlackJack.java:142)
	at java.awt.Container.update(Unknown Source)
	at sun.awt.RepaintArea.updateComponent(Unknown Source)
	at sun.awt.RepaintArea.paint(Unknown Source)
	at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


----------



## Tomate_Salat (16. Mai 2010)

Exceptions werden in roter schrift ausgegeben, aber ich erkenne, was da exception und was da eine simple ausgabe ist. Aber ich meinte: poste nochmal die CBlackJack.java, also den Sourcecode, da deine CBlackJack.java mitlerweile sich sicher verändert hat und ich sonst mit der Exception nicht viel anfangen kann


----------



## jockijo (16. Mai 2010)

den hier?


```
package paketBJ;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;




/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit [url=http://www.cloudgarden.com]Cloud Garden (Java Resources)[/url] for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class CBlackJack extends Applet implements ActionListener,Runnable{
	
private CDeck deck;
	
	private CHand spielerHand;
	private CHand geberHand;

	public Button btnZiehen=new Button("Ziehen");
	public Button btnHalten=new Button("Halten");
	public Button btnNächsteRunde=new Button("Nächste Runde");
	public Button btnNeuesSpiel=new Button("Spiel Neustart");	
	public Button btnEinzahlen=new Button("€ 50 einzahlen");
	
	Image offIm=null;
	Graphics offGraphics=null;
	
	Image[] kartenBilder = new Image[52];
	private int aktKarteLaden = 0;	
	
	int breite, höhe;
	int kartenBreite = -1;
	int anpassen = -1;	
	
	private int spiel = 0;					//Anzahl der Spiele
	private int runde = 1;					//Anzahl der Runden	
	private String message1;				//String für Meldungen
	private String message2;				//String für Meldungen
	private double geldbetrag = 50.00;		//Geldbetrag der dem Spieler zur Verfügung steht
	private double gesamtbetrag = 50.00;	//Gesamter eingesetzter Betrag des Spielers
	private double gewinnverlust = 0;		//Aktueller Gewinn/Verlust des Spielers
	private double geldeinsatz = 5.00;		//Einsatz pro Runde
	private double gewinnBlackJack = 1.5;	//Gewinnverhältnis bei einem Black Jack
 
	public void init() {	
		Thread kartenLaden = new Thread(this);
		kartenLaden.start();
	}
	
	public void run(){
		MediaTracker mt=new MediaTracker(this);
	
		for(aktKarteLaden=0; aktKarteLaden < 52; aktKarteLaden++){
		  
			kartenBilder[aktKarteLaden] = getImage(getCodeBase(),
				"Karten/" + (aktKarteLaden+1) + ".gif");
			mt.addImage(kartenBilder[aktKarteLaden],0);
			repaint();
		}		
		//Neues Deck anlegen
		deck = new CDeck(this,kartenBilder);
		
		//Breite der Kartenbilder feststellen
		kartenBreite = deck.getKarte(0).getBild().getWidth(this);

		btnZiehen.addActionListener(this);
		btnHalten.addActionListener(this);
		btnNächsteRunde.addActionListener(this);
		btnNeuesSpiel.addActionListener(this);
		btnEinzahlen.addActionListener(this);
		
		btnZiehen.setEnabled(false);
		btnHalten.setEnabled(false);
		btnNächsteRunde.setEnabled(false);
		btnEinzahlen.setEnabled(false);

		//Breite und Höhe des Applets sichern
		breite  = getSize().width;
		höhe = getSize().height;
		message1 = "";
		message2 = "";

		this.add(btnZiehen);
		this.add(btnHalten);
		this.add(btnNächsteRunde);	
		this.add(btnEinzahlen);	
		this.add(btnNeuesSpiel); 

		//Neue Kartenhände anlegen
		spielerHand = new CHand();
		geberHand = new CHand();
		
		this.validate();		
		repaint();
	}
	
	public void actionPerformed(ActionEvent ae) {
 
		if(ae.getSource() == btnNeuesSpiel) {
			neuesSpiel();
		}
		else if (ae.getSource() == btnZiehen) {
			ziehen();
		}
		else if (ae.getSource() == btnHalten) {
			halten();
		}
		else if (ae.getSource() == btnNächsteRunde)	{
			nächsteRunde();
		}
		else if (ae.getSource() == btnEinzahlen) {
			einzahlen();
		}
		   
		repaint();
	}
  
	public void paint(Graphics g) {
        if(offGraphics==null){
            offIm=createImage(getSize().width,getSize().height);
            offGraphics=offIm.getGraphics();
        }
        //Test
        System.out.println("offIm: " + offIm);
        System.out.println("offGraphics: " + offGraphics);
		
		
			Image aktKarte;

			if(kartenBreite == -1)
				//"this" zu "null" gemacht
				kartenBreite = deck.getKarte(0).getBild().getWidth(null);
			
				
			
			if(anpassen == -1)
				anpassen = (breite - (kartenBreite * 2) - 4) / 4;

			//Hintergrundfarbe setzen
			offGraphics.setColor(new Color(20,100,20));
			offGraphics.fillRect(0,0,breite,höhe);
			offGraphics.setColor(Color.white);
			
			offGraphics.drawString("Spieler: "+spielerHand.getSumme(),anpassen,40);
			//offGraphics.drawString("Spieler: "+spielerHand.getSumme(),anpassen,40);
			
			
			
			offGraphics.drawString("Geber: "+geberHand.getSumme(),(breite/2) + anpassen,40);
			offGraphics.drawString(message1,5,höhe - 94);			
			if(spiel > 0)
			{
				offGraphics.drawString("Restliche Karten: "+deck.getRestAnzahl(),5,höhe - 66);			
				offGraphics.drawString("Spiel "+spiel+" Runde "+runde,5,höhe - 38);
			}
			offGraphics.drawString(message2,5,höhe-10);
			//Anzeigen der Kartenhand des Spielers
			for(int i=0;i<spielerHand.getKartenAnzahl();i++){
				offGraphics.drawImage(spielerHand.getKarten(i).getBild(), anpassen, 70+(20*(i-1)), this);//neu
			}
			//Anzeigen der Kartenhand des Gebers
			for(int i=0;i<geberHand.getKartenAnzahl();i++){
				offGraphics.drawImage(geberHand.getKarten(i).getBild(), (breite/2 ) + anpassen, 70+(20*(i-1)), this);
			}		
		g.drawImage(offIm,0,0,this);
 
	}

public void neuesSpiel(){
		//Button für Ziehen enablen
		btnZiehen.setEnabled(true);
		//Buttons für nächste Rundek, Neues Spiel und Halten disablen
		btnHalten.setEnabled(false);
		btnNeuesSpiel.setEnabled(false);
		btnNächsteRunde.setEnabled(false);

		//Vor jedem neuen Spiel werden die Karten gemischt
		deck = new CDeck(this,kartenBilder);

		//Neue Kartenhände anlegen
		spielerHand = new CHand();
		geberHand = new CHand();
		
		//Geber und Spieler bekommen je eine Karte
		spielerHand.addKarte(deck.geben());
		geberHand.addKarte(deck.geben());
		
		//Spieler macht Einsatz
		geldbetrag = 50 - geldeinsatz;
		gesamtbetrag = 50;
		message1 = "Ihr Geldbetrag ist € "+geldbetrag;
		message2 = "";
		
		runde = 1;
		spiel++;
		
		if (geldbetrag == 0) {
			btnEinzahlen.setEnabled(true);
			btnNeuesSpiel.setEnabled(false);
		}
	}
	
	public void nächsteRunde(){
		//Button für Ziehenenablen		
		btnZiehen.setEnabled(true);
		//Buttons für nächste Runde, Neues Spiel und Halten disablen
		btnHalten.setEnabled(false);
		btnNeuesSpiel.setEnabled(false);
		btnNächsteRunde.setEnabled(false);

		//Neue Kartenhände anlegen
		spielerHand = new CHand();
		geberHand = new CHand();

		//Geber und Spieler bekommen je eine Karte
		spielerHand.addKarte(deck.geben());
		geberHand.addKarte(deck.geben());
	
		runde++;
		
		//Spieler macht Einsatz
		geldbetrag = geldbetrag - geldeinsatz;
		message1 = "Ihr Geldbetrag ist € "+geldbetrag;
	}
 
	public void ziehen(){

		btnHalten.setEnabled(true);

		spielerHand.addKarte(deck.geben());
		//Wenn der Spieler über 21 hat, dann hat er verloren
		if(spielerHand.getSumme() > 21){
			message1 = "Sie haben verloren! Sie haben noch € "+geldbetrag;
			//Buttons für Ziehen und Halten disablen
			btnZiehen.setEnabled(false);
			btnHalten.setEnabled(false);
			//Button für nächste Runde enablen, wenn Geldbetrag > 0
			if (geldbetrag > 0) {
				btnNächsteRunde.setEnabled(true);
				btnNeuesSpiel.setEnabled(true);
			}else {
				btnEinzahlen.setEnabled(true);
				btnNeuesSpiel.setEnabled(false);
			}
			//Wenn im Deck 10 Karten oder weniger sind, werden alle Karten neu gemischt
			if (deck.getRestAnzahl() < 11) {
				deck = new CDeck(this,kartenBilder);
			}
			//Gesamter Gewinn/Verlust berechnen
			message2 = gewinnVerlust();
		}		
	}

	public void halten(){

		//Geber muss nehmen, solange seine Summer unter 17 ist
		while(geberHand.getSumme() < 17){
			geberHand.addKarte(deck.geben());
		}
		//Wenn der geber mehr Punkte hat, hat der Spieler verloren
		if(geberHand.getSumme() <= 21 && spielerHand.getSumme() < geberHand.getSumme())
		{
			message1 = "Sie haben verloren! Sie haben noch € "+geldbetrag;
		}
		//wenn der Spieler einen Black Jack hat und der Geber nicht, dann hat der Spieler gewonnen
		else if (spielerHand.blackJack() && geberHand.blackJack() == false) {
			geldbetrag = geldbetrag + geldeinsatz + gewinnBlackJack*geldeinsatz;
			message1 = "Black Jack! Sie haben € "+geldeinsatz*gewinnBlackJack+" gewonnen! Sie haben jetzt € "+geldbetrag;
		}
		//Bei Gleichstand bekommt der Spieler seinen Einsatz zurück
		else if (spielerHand.getSumme() == geberHand.getSumme())
		{
			//Hat bei Gleichstand der Geber einen Black Jack, hat der Spieler verloren
			if (geberHand.blackJack() && spielerHand.blackJack() == false) {
				message1 = "Sie haben verloren! Der Geber hat Black Jack! Sie haben noch € "+geldbetrag; 
			}
			else {
				geldbetrag = geldbetrag + geldeinsatz;
				message1 = "Unentschieden! Sie haben noch € "+geldbetrag;
			}
		}
		//Wenn der Spieler mehr Punkte hat, dann hat er gewonnen
		else {
			geldbetrag = geldbetrag + 2*geldeinsatz;
			message1 = "Sie haben € "+geldeinsatz+" gewonnen! Sie haben jetzt € "+geldbetrag;
		}

		btnZiehen.setEnabled(false);
		btnHalten.setEnabled(false);
		
		if (geldbetrag > 0) {
			btnNeuesSpiel.setEnabled(true);
			btnNächsteRunde.setEnabled(true);
		}
		else {
			btnEinzahlen.setEnabled(true);
			btnNeuesSpiel.setEnabled(false);
		}
		//Wenn im Deck 10 Karten oder weniger sind, werden alle Karten neu gemischt
		if (deck.getRestAnzahl() < 11) {
			deck = new CDeck(this,kartenBilder);
		}
		
		//Gesamter Gewinn/Verlust berechnen
		message2 = gewinnVerlust();
	}
	
	public void einzahlen() {
		geldbetrag = geldbetrag + 50;
		gesamtbetrag = gesamtbetrag + 50;
		message1 = "Sie haben noch € "+geldbetrag;
		btnNächsteRunde.setEnabled(true);
		btnNeuesSpiel.setEnabled(true);
		btnEinzahlen.setEnabled(false);
	}
	
	public String gewinnVerlust() {
		//Gesamter Gewinn/Verlust berechnen
		gewinnverlust = geldbetrag - gesamtbetrag;
		if (gewinnverlust < 0) {
			return "Sie haben bist jetzt € "+(-1)*gewinnverlust+" verloren!";
		}
		else {
			return "Sie haben bist jetzt € "+gewinnverlust+" gewonnen!";
		}
	}
	
	private void initGUI() {
		try {
			{
				this.setPreferredSize(new java.awt.Dimension(491, 335));
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

}
```


----------



## Tomate_Salat (16. Mai 2010)

Ja genau. Ein Problem, warum deine Größe nicht stimmt, könnte sein: dass er das Bild erst liest wenn er es anzeigen soll. Das verhalten findet man auch bei:

```
Image img	= Toolkit.getDefaultToolkit().createImage( url );
```

Da bekommt man als Größe auch -1 zurückgeliefert. Vllt solltest du das Bild nicht über [c]createImage[/c] sondern über:


```
try
{
       Imageimg = ImageIO.read( url );
}
catch (IOException e)
{
       e.printStackTrace();
}
```

einlesen, dann würdest du zumindest mal die richtige größe bekommen. Warum du eine NP-Exception bekommst, ist mir bis jz aber noch unklar


----------



## jockijoo (16. Mai 2010)

soll ich also

try {
			{
				this.setPreferredSize(new java.awt.Dimension(491, 335));
			}
		} catch(Exception e) {
			e.printStackTrace();



durch

try
{
       Imageimg = ImageIO.read( url );
}
catch (IOException e)
{
       e.printStackTrace();
}


ersetzen?


----------



## Tomate_Salat (16. Mai 2010)

nope hier

```
public void run(){
        MediaTracker mt=new MediaTracker(this);
    
        for(aktKarteLaden=0; aktKarteLaden < 52; aktKarteLaden++){
          
            kartenBilder[aktKarteLaden] = getImage(getCodeBase(),
                "Karten/" + (aktKarteLaden+1) + ".gif");
```
das getImage(...) durch ImageIO.read(...); vllt mal ersetzen. Ich denke das ist eher das was du brauchst


----------



## jockijoo (16. Mai 2010)

dann steht, dass imageio nicht aufgelöst werden kann


----------



## Tomate_Salat (16. Mai 2010)

Naja, kürzen wirs mal ab, lasse mal deine Create stehen: haben die Karten nicht eh alle eine standartgröße? Dann kannst du dir das herausfinden der Größe erstmal sparen und ggf auf später verlagern


----------



## jockijoo (16. Mai 2010)

ok, wenn das mit den bildern nicht klappt, ist das auch nicht sooo schlimm, jedoch ist störend, dass der text nach der ersten zeile abrupt abbricht. egal, ob das fenster von meiner seite aus vergrößert wird, wird es nicht sichtbar. nur der text im grünen feld ist sichtbar.


----------



## Tomate_Salat (16. Mai 2010)

ersetze mal:

```
offGraphics.fillRect(0,0,breite,höhe);
```
durch:

```
offGraphics.fillRect(0,0,getWidth(),getHeight());
```


----------



## jockijoo (16. Mai 2010)

leider passiert nichts - immer noch der selbe fehler


----------



## Tomate_Salat (16. Mai 2010)

oder update breite + höhe (btw: umlaute in variablen sollte man sich abgewöhnen!)

```
breite = getWidth();
höhe = getHeight();
```

weil du die ja mehrmals verwendest, sollte zumindest beim vergrößern des Applets sich bemerkbar machen


----------

