Guten Tag
ich versuche mit Eclipse Juno einen Taschenrechner zu erstellen
bin aber mit meinem jetzigen Javawissen am Ende.
Ich programmiere noch nicht lange
Kann mir jmd. helfen???
Quellcode:
Start.java:
public class Start {
static Fenster f;
public static void main(String[] args) {
f=new Fenster("Fensterprogramm",800,600);
}
}
Fenster.java:
import java.awt.Button;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
public class Fenster extends Frame implements WindowListener, ActionListener{
Button Ba,Bs,Bm,Bd,Erg;
TextField T1,T2,T3;
Label L0;
public Fenster(String titel, int breite, int hoehe) {
this.setTitle(titel);
this.setSize(breite,hoehe);
this.setLayout(null);
Ba = new Button("+");
Ba.setLocation(150,30);
Ba.setSize(20,20);
this.add(Ba);
Bs = new Button("-");
Bs.setLocation(150,60);
Bs.setSize(20,20);
this.add(Bs);
Bm = new Button("*");
Bm.setLocation(150,90);
Bm.setSize(20,20);
this.add(Bm);
Bd = new Button(":");
Bd.setLocation(150,120);
Bd.setSize(20,20);
this.add(Bd);
T1 = new TextField(20);
T1.setLocation(50,75);
T1.setSize(75,20);
this.add(T1);
T2 = new TextField(20);
T2.setLocation(195,75);
T2.setSize(75,20);
this.add(T2);
Erg = new Button("=");
Erg.setLocation(295,75);
Erg.setSize(20,20);
this.add(Erg);
this.addWindowListener(this);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e1) {
if (e1.getSource() == Ba) {
if (e1.getSource() == Erg) {
System.out.println(Integer.parseInt(T1.getText()) + Integer.parseInt(T2.getText()));
}
}
}
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent arg0) {
System.exit(0);
}
@Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}