Problem bei Java Programierung

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Problem bei Java Programierung

    Wer kann mir helfen, denn Fehler zu beseitigen!







    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.lang.Math;

    public class Testit extends Applet
    {
    Button button1 = new Button();
    Label label1 = new Label();
    Label label2 = new Label();
    private int wuerfel;

    public void init()
    {
    try
    {
    jbInit();
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }

    private void jbInit() throws Exception
    {
    this.setLayout(null);
    label1.setText("Durch einen Zufallsgenerator soll ein Wochentag bestimmt werden");
    label1.setBounds(new Rectangle(2, 2, 499, 44));

    button1.setBackground(Color.green);
    button1.setFont(new java.awt.Font("Dialog", 0, 20));
    button1.setLabel("Tag ?");
    button1.setBounds(new Rectangle(106, 52, 153, 98));
    button1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
    button1_actionPerformed(e);
    }
    });
    label2.setFont(new java.awt.Font("SansSerif", 1, 24));
    label2.setBounds(new Rectangle(126, 172, 166, 69));
    this.add(label1, null);
    this.add(button1, null);
    this.add(label2, null);
    }

    public void paint (Graphics g)
    {

    }

    void button1_actionPerformed(ActionEvent e)
    {

    wuerfel=(int)(Math.random() * 6) +1 ;

    switch (wuerfel)
    {

    case 1 : g.setColor(Color.white);
    g.fillOval(140,190,20,20);; break;
    case 2 : g.setColor(Color.white);
    g.fillOval(115,220,20,20);
    g.fillOval(165,160,20,20);; break;
    case 3 : g.setColor(Color.white);
    g.fillOval(115,220,20,20);
    g.fillOval(165,160,20,20);
    g.fillOval(140,190,20,20);;break;
    case 4 : g.setColor(Color.white);
    g.fillOval(115,220,20,20);
    g.fillOval(165,160,20,20);
    g.fillOval(115,160,20,20);
    g.fillOval(165,220,20,20);; break;
    case 5 : g.setColor(Color.white);
    g.fillOval(115,220,20,20);
    g.fillOval(165,160,20,20);
    g.fillOval(115,160,20,20);
    g.fillOval(165,220,20,20);
    g.fillOval(140,190,20,20);; break;
    case 6 : g.setColor(Color.white);
    g.fillOval(115,160,20,20);
    g.fillOval(115,190,20,20);
    g.fillOval(115,220,20,20);
    g.fillOval(165,160,20,20);
    g.fillOval(165,190,20,20);
    g.fillOval(165,220,20,20);; break;
    }

    }

    }