Hallo,
hab da meine Gui, in der ich zwei Buttons implementiert habe, nur bekomm ich da Fehlermeldungen, mit denen ich wenig anfangen kann. hier der Code:
hab da meine Gui, in der ich zwei Buttons implementiert habe, nur bekomm ich da Fehlermeldungen, mit denen ich wenig anfangen kann. hier der Code:
Java:
package getATR;
import java.awt.event.ActionEvent;
public class GUI_ATR extends JFrame{
// Meine Button
public static JButton daten_pruefen = new JButton("Daten pruefen");
public static JButton pruefung_abschließen = new JButton("Pruefung abschliessen");
public static JLabel lblKartennr = new JLabel("* Karten-Nr.:");
public static JFormattedTextField txtFKartennr = new JFormattedTextField();
public static JTextArea textArea = new JTextArea();
private final JScrollPane scrollPane = new JScrollPane();
static File f;
static String path_f;
static int returnVal;
public GUI_ATR() {
setTitle("TEST");
this.setVisible(true);
setSize(1010, 532);
setLocation(150, 100);
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
JPanel panel = new JPanel();
getContentPane().add(panel);
panel.setLayout(null);
// Daten prüfen Button
panel.add(daten_pruefen);
daten_pruefen.setSize(70, 35);
daten_pruefen.setLocation(5, 5);
// Prüfung abschließen Button
panel.add(pruefung_abschließen);
pruefung_abschließen.setSize(95, 35);
pruefung_abschließen.setLocation(350, 5);
// Karten-Nr.:
lblKartennr.setBounds(458, 259, 81, 14);
panel.add(lblKartennr);
lblKartennr.setVisible(false);
txtFKartennr.setBounds(579, 256, 100, 20);
panel.add(txtFKartennr);
txtFKartennr.setVisible(false);
// Text Area
scrollPane.setBounds(5, 45, 440, 455);
panel.add(scrollPane);
scrollPane.setViewportView(textArea);
addWindowListener(new meinWindowListener());
// unten auskommentierte: The method addActionListener(ActionListener) in the type
// AbstractButton is not applicable for the arguments (GUI_ATR)
/*daten_pruefen.addActionListener(this);
pruefung_abschließen.addActionListener(this);*/
/////////////////////////////////////////////////
// Daten prüfen Button
/////////////////////////////////////////////////
daten_pruefen.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
open_terminal();
karteninhalt_auslesen.init_log_command_list();
if (e.getSource() == this.daten_pruefen) { //Fehlermeldung "daten_pruefen can't be resolved or is not a field"
gui_leeren();
open_terminal();
if (Connect_Terminal.isTerminal_present() == true) {
open_card();
if (Connect_Card.isCard_present() == true) {
lblKartennr.setVisible(true);
txtFKartennr.setVisible(true);
String inhalt = txtFKartennr.getText();
System.out.println(inhalt);
init_osVersion();
try {
//Karteninhalt ausgeben
karteninhalt_auslesen.ausgabe_auswahl();
} catch (CardException e1) {
e1.printStackTrace();
}
} else {
GUI_ATR.textArea.append("Keine Karte vorhanden");
}
} else {
GUI_ATR.textArea.append("Chipkartenleser ist nicht eingesteckt");
}
}
}
});
/////////////////////////////////////////////////
// Prüfung abschließen Button
/////////////////////////////////////////////////
pruefung_abschließen.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
if (e.getSource() == this.pruefung_abschließen) { //Fehlermeldung "pruefung_abschließen can't be resolved or is not a field"
gui_leeren();
open_terminal();
GUI_ATR.textArea.append("...Formular geleert!");
}
}
});}
public void gui_leeren(){
// um mein Textfeld zu leeren
textArea.setText("");
lblKartennr.setVisible(false);
txtFKartennr.setVisible(false);
txtFKartennr.setText("");
}
public static void init_osVersion() {
Inhalt_ATR.init_ATR();
Inhalt_ATR.convert_atr();
Inhalt_ATR.init_all_Maps();
Inhalt_ATR.set_all_Variables();
}
public static void open_terminal() {
Connect_Terminal.create_factory();
try {
Connect_Terminal.create_terminals(0);
} catch (CardException e2) {
textArea.append(e2.toString());
} catch (Exception e2) {
textArea.append(e2.toString());
}
}
public static void open_card() {
try {
Connect_Card.newCard();
} catch (CardException e1) {
GUI_ATR.textArea.append(e1.toString());
}
}
public static void File_chooser() throws IOException {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
returnVal = fc.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
setF(fc.getSelectedFile());
setPath_f(f.getPath());
}
}
public static File getF() {
return f;
}
public static void setF(File f) {
GUI_ATR.f = f;
}
public static String getPath_f() {
return path_f;
}
public static void setPath_f(String path_f) {
GUI_ATR.path_f = path_f;
}
public class meinWindowListener extends WindowAdapter {
public void windowClosing(WindowEvent a) {
System.exit(0);
}
}
}
Zuletzt bearbeitet: