LegendaryBeazt
Mitglied
Folgendes Programm:
Bei if(source==b1 && angabe == 0.80); wird mir ein Fehler angezeigt, incopatible operand types JTextField and double.
Ich habe versucht, das Textfeld angabe auf JFormattedTextField zu setzen, der Fehler war aber immernoch da.
Bitte um hilfe
Danke im voraus
Viele Grüße
LegendaryBeazt
PHP:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.naming.Reference;
import javax.swing.*;
import com.sun.org.apache.xerces.internal.impl.xs.opti.DefaultDocument;
import com.sun.xml.internal.txw2.Document;
public class Parkscheinautomat extends JFrame implements ActionListener {
JButton b1 = new JButton(" Bestätigen"); //Alle Objekte hier, dann sind sie keine
JButton b2 = new JButton(" Löschen"); // lokalen variablen mehr!!
JFrame frame = new JFrame();
JTextField angabe = new JTextField ();
JPanel panel = new JPanel();
JTextArea textfeld = new JTextArea(11,20);
JTextField ausgabe = new JTextField(15);
JLabel l1 = new JLabel("Eingabe Betrag: ");
JLabel l2 = new JLabel("Ihre Parkzeit : ");
public Parkscheinautomat() {
super("Parkscheinautomat");
textfeld.setText("Zahlungsmöglichkeiten:\n" +
"Es ist ausschließlich Bar zu zahlen!\n" +
"-----------------------\n" +
"Parkgebühren:\n" +
"30 Minuten = € 0,80\n" +
"1 Stunde = € 1,60\n" +
"2 Stunden = € 3,20\n" +
"-----------------------\n" +
"Höchstparkdauer:\n" +
"2 Stunden\n" );
JScrollPane scrollpane = new JScrollPane(textfeld);
textfeld.setEditable(false);
ausgabe.setEditable(false);
b1.addActionListener(this);
b2.addActionListener(this);
panel.setLayout(new BoxLayout(panel,BoxLayout.PAGE_AXIS));
panel.add(scrollpane);
panel.add(l1);
panel.add(angabe);
panel.add(b1);
panel.add(b2);
panel.add(l2);
panel.add(ausgabe);
add(panel);
pack(); //Objekte nehmen die Größe, die sie brauchen
}
public static void main(String[] arguments) {
Parkscheinautomat PA = new Parkscheinautomat();
// PA.setSize(500,500); //Wird wegen pack(); nicht mehr benötigt
PA.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
PA.setResizable(false);
PA.setLocationRelativeTo(null);
PA.setVisible(true);
}
public void actionPerformed(ActionEvent evt){
Object source = evt.getSource();
if (source == b1 && angabe==0.80);
ausgabe.setText("Sie dürfen 30 Minuten Parken!");
/*else*/ if (source == b2)
angabe.setText("");
//repaint();
}
}
Bei if(source==b1 && angabe == 0.80); wird mir ein Fehler angezeigt, incopatible operand types JTextField and double.
Ich habe versucht, das Textfeld angabe auf JFormattedTextField zu setzen, der Fehler war aber immernoch da.
Bitte um hilfe
Danke im voraus

Viele Grüße
LegendaryBeazt