Nero
2005-06-26, 13:49:29
So ich lern heute heute für ne Arbeit in der Schule. Thema ist Java Programmierung, nun hab ich das Problem das, dass Programm nicht startet. Hier ist der Quellcode:
Kontoframe.java:
//David
package kontoframe;
//Verwendung von Javaklassen
import java.awt.*;
import java.awt.event.*;
public class KontoFrame extends Frame implements ActionListener
{
//Attribute
private Konto meinKonto = new Konto();
private Label lbKontonummer = new Label ("Kontonummer");
private Label lbKontostand = new Label ("Kontostand");
private Label lbBetrag = new Label ("Betrag");
private TextField tfKontonummer = new TextField (15);
private TextField tfKontostand = new TextField (15);
private TextField tfBetrag = new TextField (15);
private Label lbnewLabel = new Label ();
private Button btEinzahlen = new Button ("Einzahlen");
private Button btAuszahlen = new Button ("Auszahlen");
//Konstruktur
public KontoFrame()
{
//Größe des Fensters
this.setSize(350,250);
//Hintergrundfarbe
this.setBackground(Color.DARK_GRAY);
//Titel
this.setTitle ("Konto");
//Layout-Manager
this.setLayout(new GridLayout (4,2,8,8));
//Dialogelemente einfügen
this.add(lbKontonummer);
this.add(tfKontonummer);
this.add(lbKontostand);
this.add(tfKontostand);
this.add(lbBetrag);
this.add(tfBetrag);
this.add(btEinzahlen);
this.add(btAuszahlen);
btEinzahlen.addActionListener(this);
meinKonto.setDKontostand(10000);
meinKonto.setSKontonummer("45789");
tfKontonummer.setText(meinKonto.getSKontonummer());
tfKontostand.setText(meinKonto.getDKontostand());
tfKontonummer.setEditable(false);
tfKontostand.setEditable(false);
//Schließen des Fensters
this.addWindowListener (new WindowAdapter()
{public void windowClosing (WindowEvent evt)
{System.exit(0);}});
//Fenster sichtbar machen
this.setVisible(true);
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent arg0)
{
String sBetrag;
sBetrag =tfBetrag.getText();
double dBetrag;
dBetrag = Double.parseDouble(sBetrag);
meinKonto.einzahlen(dBetrag);
tfKontonummer.setText(meinKonto.getSKontonummer());
tfKontostand.setText(meinKonto.getDKontostand()+"");
tfBetrag.setText("");
}}
Konto.java:
// David
package kontoframe;
public class Konto {
public void einzahlen(double betrag) {
public String getSKontonummer() {
return null;
}
public String getDKontostand() {
return null;
}
public void setDKontostand(int i) {
}
public void setSKontonummer(String string) {
}
}
Startklasse:
//David
package kontoframe;
public class Startklasse {
public static void main(String[] args) {
}
}
Ich bin ja der Meinung das was bei der Startklasse fehlt, aber ich weiß nicht was.
Kontoframe.java:
//David
package kontoframe;
//Verwendung von Javaklassen
import java.awt.*;
import java.awt.event.*;
public class KontoFrame extends Frame implements ActionListener
{
//Attribute
private Konto meinKonto = new Konto();
private Label lbKontonummer = new Label ("Kontonummer");
private Label lbKontostand = new Label ("Kontostand");
private Label lbBetrag = new Label ("Betrag");
private TextField tfKontonummer = new TextField (15);
private TextField tfKontostand = new TextField (15);
private TextField tfBetrag = new TextField (15);
private Label lbnewLabel = new Label ();
private Button btEinzahlen = new Button ("Einzahlen");
private Button btAuszahlen = new Button ("Auszahlen");
//Konstruktur
public KontoFrame()
{
//Größe des Fensters
this.setSize(350,250);
//Hintergrundfarbe
this.setBackground(Color.DARK_GRAY);
//Titel
this.setTitle ("Konto");
//Layout-Manager
this.setLayout(new GridLayout (4,2,8,8));
//Dialogelemente einfügen
this.add(lbKontonummer);
this.add(tfKontonummer);
this.add(lbKontostand);
this.add(tfKontostand);
this.add(lbBetrag);
this.add(tfBetrag);
this.add(btEinzahlen);
this.add(btAuszahlen);
btEinzahlen.addActionListener(this);
meinKonto.setDKontostand(10000);
meinKonto.setSKontonummer("45789");
tfKontonummer.setText(meinKonto.getSKontonummer());
tfKontostand.setText(meinKonto.getDKontostand());
tfKontonummer.setEditable(false);
tfKontostand.setEditable(false);
//Schließen des Fensters
this.addWindowListener (new WindowAdapter()
{public void windowClosing (WindowEvent evt)
{System.exit(0);}});
//Fenster sichtbar machen
this.setVisible(true);
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent arg0)
{
String sBetrag;
sBetrag =tfBetrag.getText();
double dBetrag;
dBetrag = Double.parseDouble(sBetrag);
meinKonto.einzahlen(dBetrag);
tfKontonummer.setText(meinKonto.getSKontonummer());
tfKontostand.setText(meinKonto.getDKontostand()+"");
tfBetrag.setText("");
}}
Konto.java:
// David
package kontoframe;
public class Konto {
public void einzahlen(double betrag) {
public String getSKontonummer() {
return null;
}
public String getDKontostand() {
return null;
}
public void setDKontostand(int i) {
}
public void setSKontonummer(String string) {
}
}
Startklasse:
//David
package kontoframe;
public class Startklasse {
public static void main(String[] args) {
}
}
Ich bin ja der Meinung das was bei der Startklasse fehlt, aber ich weiß nicht was.