x-treme888
Lieutenant
- Registriert
- Juni 2006
- Beiträge
- 995
Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
Compiliere C:\Dokumente und Einstellungen\Renko\Desktop\Java\Neuer Ordner\Neuer Ordner\mit print\Neuer Ordner\Rechner.java mit Java-Compiler
Rechner.java:168:11: exit(int) in java.lang.System cannot be applied to ()
System.exit();
^
1 error
import java.awt.*;
import java.awt.event.*;
/**
*
* Beschreibung
*
* @version 1.0 vom 23.09.2007
* @author
*/
public class Rechner extends Frame {
// Anfang Variablen
double zahl1, zahl2, zahl3, ergebnis ;
private TextField textField1 = new TextField();
private TextField textField2 = new TextField();
private TextField textField3 = new TextField();
private Button button1 = new Button();
private Button button2 = new Button();
private Button button3 = new Button();
private Button button4 = new Button();
private Button button5 = new Button();
private TextField textField4 = new TextField();
private Button button6 = new Button();
// Ende Variablen
public Rechner(String title) {
// Frame-Initialisierung
super(title);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) { System.exit(0); }
});
int frameWidth = 600;
int frameHeight = 600;
setSize(frameWidth, frameHeight);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int x = (d.width - getSize().width) / 2;
int y = (d.height - getSize().height) / 2 ;
setLocation(x, y);
Panel cp = new Panel(null);
add(cp);
// Anfang Komponenten
textField1.setBounds(30, 40, 100, 50);
textField1.setText("");
cp.add(textField1);
textField2.setBounds(470, 40, 100, 50);
textField2.setText("");
cp.add(textField2);
textField3.setBounds(250, 40, 100, 50);
textField3.setText("");
cp.add(textField3);
button1.setBounds(248, 88, 57, 33);
button1.setLabel("+");
cp.add(button1);
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button1ActionPerformed(evt);
}
});
button2.setBounds(336, 88, 25, 33);
button2.setLabel("-");
cp.add(button2);
button2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button2ActionPerformed(evt);
}
});
button3.setBounds(376, 88, 25, 33);
button3.setLabel("*");
cp.add(button3);
button3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button3ActionPerformed(evt);
}
});
button4.setBounds(440, 96, 57, 33);
button4.setLabel("/");
cp.add(button4);
button4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button4ActionPerformed(evt);
}
});
button5.setBounds(120, 208, 73, 25);
button5.setLabel("Löschen");
cp.add(button5);
button5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button5ActionPerformed(evt);
}
});
textField4.setBounds(264, 200, 65, 24);
textField4.setText("");
cp.add(textField4);
button6.setBounds(368, 200, 113, 81);
button6.setLabel("button6");
cp.add(button6);
button6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
button6ActionPerformed(evt);
}
});
// Ende Komponenten
setResizable(false);
setVisible(true);
}
// Anfang Ereignisprozeduren
public void button1ActionPerformed(ActionEvent evt) {
zahl1 = Double.parseDouble (textField1.getText ());
zahl2 = Double.parseDouble (textField2.getText ());
zahl3 = Double.parseDouble (textField3.getText ());
ergebnis= zahl1+zahl2+zahl3;
textField4.setText(""+ergebnis);
}
public void button2ActionPerformed(ActionEvent evt) {
zahl1= Double.parseDouble (textField1.getText ());
zahl2= Double.parseDouble (textField2.getText ());
zahl3= Double.parseDouble (textField3.getText ());
ergebnis= zahl1-zahl2-zahl3;
textField4.setText(""+ergebnis);
}
public void button3ActionPerformed(ActionEvent evt) {
zahl1= Double.parseDouble (textField1.getText ());
zahl2= Double.parseDouble (textField2.getText ());
zahl3= Double.parseDouble (textField3.getText ());
ergebnis= zahl1*zahl2*zahl3;
textField4.setText (""+ergebnis);
}
public void button4ActionPerformed(ActionEvent evt) {
zahl1= Double.parseDouble (textField1.getText ());
zahl2= Double.parseDouble (textField2.getText ());
zahl3= Double.parseDouble (textField3.getText ());
ergebnis= zahl1/zahl2/zahl3;
textField4.setText (""+ergebnis);
if (zahl2!= 0 && zahl3!= 0 ) {
} else {textField4.setText (""+999);
}
}
public void button5ActionPerformed(ActionEvent evt) {
textField1.setText (""+0);
textField2.setText (""+0);
textField3.setText (""+0);
textField4.setText (""+0);
}
public void button6ActionPerformed(ActionEvent evt) {
System.exit();
}
// Ende Ereignisprozeduren
public static void main(String[] args) {
new Rechner("Rechner");
}
}