D
Dominik2811
Gast
Hi,
ich bin momentan am verzweifeln... egal was ich mache... meine buttons gehen einfach nicht.... ich stell hier einfach mal den programmtext rein:
APPLET TISCH
KLASSE KARTE
KLASSE GEOPOS
KLASSE KARTENDEKO
L-ectron-X hat am 07.05.2006 um 19:55 Uhr die Codetags gesetzt und den Titel angepasst.
ich bin momentan am verzweifeln... egal was ich mache... meine buttons gehen einfach nicht.... ich stell hier einfach mal den programmtext rein:
APPLET TISCH
Code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Tisch extends Applet implements ActionListener
{
Label ueberschrift,a,b,c,d,e,f,g,h,i,ausgabe,ausgabe2,ausgabe3,ausgabe4,bj;
Button neu,mehr,bestaetigen;
karte k1,k2,k3,k4;
kartendeko kd;
Graphics stift;
int n,m;
public void init()
{
this.setLayout(null);
this.setBackground(new Color (40,140,60));
this.setForeground(Color.white);
n = 26;
m = 427;
k1= new karte();
k2= new karte();
k3= new karte();
k4= new karte();
kd= new kartendeko();
ausgabe = new Label("TEST!");
ausgabe.setBounds(100,393,50,10);
ausgabe2 = new Label ("TEST");
ausgabe2.setBounds(100,414,50,10);
ausgabe3 = new Label("TEST!");
ausgabe3.setBounds(220,157,50,10);
ausgabe4 = new Label ("TEST");
ausgabe4.setBounds(220,181,50,10);
ueberschrift = new Label ("BLACK JACK");
ueberschrift.setFont(new Font("Monoscpaced",Font.BOLD,26));
ueberschrift.setBounds(210,5,190,35);
bj = new Label ("BLACK JACK");
bj.setFont(new Font("Monoscpaced",Font.BOLD,8));
bj.setBounds(478,285,55,8);
a = new Label ("Ergebnis des PC-Gegners:");
a.setFont(new Font("Monoscpaced",Font.BOLD,13));
a.setBounds(50,150,170,25);
b = new Label ("Ihr Aktuelles Ergebnis:");
b.setFont(new Font("Monoscpaced",Font.BOLD,13));
b.setBounds(50,175,150,25);
c = new Label ("Punkte:");
c.setFont(new Font("Monoscpaced",Font.BOLD,15));
c.setBounds(50,360,190,17);
d = new Label ("_______________");
d.setFont(new Font("Monoscpaced",Font.BOLD,12));
d.setBounds(0,363,150,18);
e = new Label ("Gegner:");
e.setFont(new Font("Monoscpaced",Font.BOLD,12));
e.setBounds(50,390,50,17);
f = new Label ("Spieler:");
f.setFont(new Font("Monoscpaced",Font.BOLD,12));
f.setBounds(50,410,50,18);
neu = new Button ("Neues Spiel");
neu.addActionListener(this);
neu.setForeground(Color.black);
neu.setBounds(458,70,85,25);
mehr = new Button ("Noch Eine!");
mehr.addActionListener(this);
mehr.setForeground(Color.black);
mehr.setBounds(458,100,85,25);
bestaetigen = new Button ("Zug beenden");
bestaetigen.addActionListener(this);
bestaetigen.setForeground(Color.black);
bestaetigen.setBounds(458,130,85,25);
this.add(ueberschrift);
this.add(a);
this.add(b);
this.add(c);
this.add(d);
this.add(e);
this.add(f);
this.add(bj);
this.add(neu);
this.add(mehr);
this.add(ausgabe);
this.add(ausgabe2);
this.add(ausgabe3);
this.add(ausgabe4);
this.add(bestaetigen);
}
public void paint (Graphics stift)
{
stift.drawLine(0,50,550,50);
stift.drawLine(0,447,550,447);
stift.setColor(new Color (20,110,10));
stift.fillRect(455,55,90,393);
stift.setColor(Color.white);
stift.fillRect(450,50,100,9);
stift.fillRect(450,439,100,9);
stift.fillRect(447,50,9,398);
stift.fillRect(545,50,9,398);
kd.paint(stift);
stift.setColor(Color.red);
while (n<422)
{
n= n+33;
stift.fillRect(545,n,9,17);
stift.fillRect(447,n,9,17);
}
while (m<524)
{
m= m+33;
stift.fillRect(m,50,17,9);
stift.fillRect(m,439,17,9);
}
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand() == "Neues Spiel")
{
k1.verschieben(30,100);
k1.wuerfeln();
k1.paint(stift);
k1.lesen();
}
if (e.getActionCommand() == "Noch Eine!")
{
k2.wuerfeln();
k2.paint(stift);
}
if (e.getActionCommand() == "Zug beenden")
{
}
}
}
KLASSE KARTE
Code:
import java.awt.* ;
public class karte extends GeoPos
{
int zahl;
public void wuerfeln()
{
zahl=(int) (11*Math.random()) + 1;
}
public int lesen ()
{
return zahl;
}
public karte()
{
super();
zahl=(int) (11*Math.random()) + 1;
}
public void paint (Graphics stift)
{
stift.setColor(Color.white);
stift.fillRect(Xpos,Ypos+120,70,100);
stift.setColor(Color.black);
stift.drawRect(Xpos,Ypos+120,70,100);
if (zahl == 1)
{
stift.fillOval(Xpos+20,Ypos+140,10,10);
}
if (zahl == 2)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
}
if (zahl == 3)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
stift.fillOval(Xpos+20,Ypos+140,10,10);
}
if(zahl == 4)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
stift.fillOval(Xpos+5,Ypos+150,10,10);
stift.fillOval(Xpos+35,Ypos+130,10,10);
}
if (zahl == 5)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
stift.fillOval(Xpos+5,Ypos+150,10,10);
stift.fillOval(Xpos+35,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+140,10,10);
}
if (zahl == 6)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+150,10,10);
stift.fillOval(Xpos+5,Ypos+150,10,10);
stift.fillOval(Xpos+35,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
}
if (zahl == 7)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+150,10,10);
stift.fillOval(Xpos+5,Ypos+150,10,10);
stift.fillOval(Xpos+35,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
}
if (zahl == 8)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+150,10,10);
stift.fillOval(Xpos+5,Ypos+150,10,10);
stift.fillOval(Xpos+35,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
}
if (zahl == 9)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+150,10,10);
stift.fillOval(Xpos+5,Ypos+150,10,10);
stift.fillOval(Xpos+35,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
}
if (zahl == 10)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+150,10,10);
stift.fillOval(Xpos+5,Ypos+150,10,10);
stift.fillOval(Xpos+35,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
}
if (zahl == 11)
{
stift.fillOval(Xpos+5,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+150,10,10);
stift.fillOval(Xpos+5,Ypos+150,10,10);
stift.fillOval(Xpos+35,Ypos+130,10,10);
stift.fillOval(Xpos+20,Ypos+130,10,10);
stift.fillOval(Xpos+35,Ypos+150,10,10);
}
}
}
KLASSE GEOPOS
Code:
public class GeoPos
{
int Xpos, Ypos;
public GeoPos()
{
Xpos = 150;
Ypos = 50;
}
public void verschieben(int neuX, int neuY)
{
Xpos = neuX;
Ypos = neuY;
}
}
KLASSE KARTENDEKO
Code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class kartendeko
{
public void paint (Graphics stift)
{
stift.fillRect(464,270,70,100);
stift.setColor(Color.black);
stift.drawRect(464,270,70,100);
stift.setColor(Color.white);
stift.fillRect(466,270,70,100);
stift.setColor(Color.black);
stift.drawRect(466,270,70,100);
stift.setColor(Color.white);
stift.fillRect(468,270,70,100);
stift.setColor(Color.black);
stift.drawRect(468,270,70,100);
stift.setColor(Color.white);
stift.fillRect(470,270,70,100);
stift.setColor(Color.black);
stift.drawRect(470,270,70,100);
stift.setColor(Color.red);
stift.fillRect(473,272,64,96);
stift.setColor(Color.white);
stift.fillRect(476,275,58,90);
}
}
L-ectron-X hat am 07.05.2006 um 19:55 Uhr die Codetags gesetzt und den Titel angepasst.