Advertisement
Cihat47

Cihat47

Jun 17th, 2011
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.28 KB | None | 0 0
  1.  /*hier die ganze Gui Klasse mit den einzelnen Fehlermeldungen! Wenn ich die einzelnen Buttons
  2.   mit ActionListener bestücke, dann werd ich von Fehlermeldungen überschüttet.
  3.   Mit der anderen Variante funktioniert alles einwandfrei, also wenn mein ActionListener schon
  4.   in der Zeile: class GUI_ATR extends JFrame implements ActionListener{ implementiert ist!
  5.   Nur brauch ich das ja nicht in der Form :(
  6.   hoff du kannst mir bei den Fehlermeldungen helfen. gruß*/
  7.  
  8. package getATR;
  9.  
  10. import java.awt.event.ActionEvent;
  11. import java.awt.event.ActionListener;
  12. import java.awt.event.WindowAdapter;
  13. import java.awt.event.WindowEvent;
  14. import java.io.File;
  15. import java.io.IOException;
  16. import javax.smartcardio.CardException;
  17. import javax.swing.*;
  18. import javax.swing.JFormattedTextField;
  19. import javax.swing.JFrame;
  20. import javax.swing.JLabel;
  21. import javax.swing.JPanel;
  22.  
  23. public class GUI_ATR extends JFrame{
  24.    
  25.     // Meine Button
  26.     public static JButton daten_pruefen = new JButton();
  27.     public static JButton pruefung_abschließen = new JButton();
  28.    
  29.    
  30.     public static JLabel lblKartennr = new JLabel("* Karten-Nr.:");
  31.     public static JFormattedTextField txtFKartennr;
  32.  
  33.     public static JTextArea textArea = new JTextArea();
  34.     private final JScrollPane scrollPane = new JScrollPane();
  35.    
  36.     static File f;
  37.     static String path_f;
  38.     static int returnVal;
  39.    
  40.     public void gui_leeren() {
  41.        
  42.         // um mein Textfeld zu leeren
  43.         textArea.setText("");
  44.         lblKartennr.setVisible(false);                 
  45.         txtFKartennr.setVisible(false);
  46.        
  47.     }     // Fehlermeldung Multiple markers at this line. Syntax error on token "}",
  48.           // delete this token ...versteh aber nicht warum!
  49.           // Ich schließ hier meine Klammer ganz normal, deshalb bin ich etwas verwirrt!
  50.    
  51.    
  52.  
  53.     /////////////////////////////////////////////////
  54.     // Daten prüfen Button
  55.     /////////////////////////////////////////////////
  56.     daten_pruefen.addActionListener(new ActionListener(){  
  57.     public void actionPerformed(ActionEvent e) {
  58.         open_terminal();
  59.         karteninhalt_auslesen.init_log_command_list();
  60.         if (e.getSource() == this.daten_pruefen) {    //Fehlermeldung "daten_pruefen can't be resolved or is not a field"
  61.             gui_leeren();
  62.             open_terminal();
  63.             if (Connect_Terminal.isTerminal_present() == true) {
  64.                 open_card();
  65.                 if (Connect_Card.isCard_present() == true) {
  66.                    
  67.                    
  68.                     lblKartennr.setVisible(true);
  69.                     txtFKartennr.setVisible(true);
  70.                     init_osVersion();
  71.                     try {
  72.                        
  73.                         //Karteninhalt ausgeben
  74.                         karteninhalt_auslesen.ausgabe_auswahl();
  75.                    
  76.                     } catch (CardException e1) {
  77.                         e1.printStackTrace();
  78.                     }
  79.                    
  80.                 } else {
  81.                     GUI_ATR.textArea.append("Keine Karte vorhanden");
  82.                    
  83.                 }
  84.             } else {
  85.                 GUI_ATR.textArea.append("Chipkartenleser ist nicht eingesteckt");
  86.             }
  87.         }
  88.     }
  89.     });
  90.        
  91.        
  92.         /////////////////////////////////////////////////
  93.         // Prüfung abschließen Button
  94.         /////////////////////////////////////////////////
  95.    
  96.         pruefung_abschließen.addActionListener(new ActionListener(){
  97.         public void actionPerformed(ActionEvent e){
  98.         if (e.getSource() == this.pruefung_abschließen) {  //Fehlermeldung "pruefung_abschließen can't be resolved or is not a field"
  99.        
  100.             gui_leeren();
  101.             open_terminal();
  102.            
  103.             GUI_ATR.textArea.append("...Formular geleert!");
  104.         }      
  105.     }
  106.     });  // Fehlermeldung "Syntax Error"
  107.    
  108.    
  109.    
  110.    
  111.     public static void init_osVersion() {
  112.         Inhalt_ATR.init_ATR();
  113.         Inhalt_ATR.convert_atr();
  114.         Inhalt_ATR.init_all_Maps();
  115.         Inhalt_ATR.set_all_Variables();
  116.     }
  117.    
  118.  
  119.     public static void open_terminal() {
  120.         Connect_Terminal.create_factory();
  121.         try {
  122.             Connect_Terminal.create_terminals(0);
  123.         } catch (CardException e2) {
  124.             textArea.append(e2.toString());
  125.         } catch (Exception e2) {
  126.             textArea.append(e2.toString());
  127.         }
  128.     }
  129.  
  130.     public static void open_card() {
  131.         try {
  132.             Connect_Card.newCard();
  133.         } catch (CardException e1) {
  134.             GUI_ATR.textArea.append(e1.toString());
  135.         }
  136.     }
  137.  
  138.     public static void File_chooser() throws IOException {
  139.         JFileChooser fc = new JFileChooser();
  140.         fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  141.         returnVal = fc.showOpenDialog(null);
  142.  
  143.         if (returnVal == JFileChooser.APPROVE_OPTION) {
  144.             setF(fc.getSelectedFile());
  145.             // System.out.println(f.getPath());
  146.             setPath_f(f.getPath());
  147.         }
  148.     }
  149.  
  150.     public static File getF() {
  151.         return f;
  152.     }
  153.  
  154.     public static void setF(File f) {
  155.         GUI_ATR.f = f;
  156.     }
  157.  
  158.     public static String getPath_f() {
  159.         return path_f;
  160.     }
  161.  
  162.     public static void setPath_f(String path_f) {
  163.         GUI_ATR.path_f = path_f;
  164.     }
  165.  
  166.     public GUI_ATR() {
  167.         setTitle("TEST");
  168.        
  169.         this.setVisible(true);
  170.         setSize(1010, 532);
  171.         setLocation(150, 100);
  172.         setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
  173.         JPanel panel = new JPanel();
  174.         getContentPane().add(panel);
  175.         panel.setLayout(null);
  176.        
  177.         // Daten prüfen Button
  178.        
  179.         panel.add(daten_pruefen);
  180.         daten_pruefen.setSize(70, 35);
  181.         daten_pruefen.setLocation(5, 5);
  182.         daten_pruefen.setText("<html>Daten<br>pruefen</html>");
  183.    
  184.         // Prüfung abschließen Button
  185.        
  186.         panel.add(pruefung_abschließen);
  187.         pruefung_abschließen.setSize(95, 35);
  188.         pruefung_abschließen.setLocation(350, 5);
  189.         pruefung_abschließen.setText("<html>Pruefung<br>abschliessen</html>");
  190.  
  191.         // Karten-Nr.:
  192.         lblKartennr.setBounds(458, 259, 81, 14);
  193.         panel.add(lblKartennr);
  194.         lblKartennr.setVisible(false);
  195.        
  196.         txtFKartennr = new JFormattedTextField();
  197.         txtFKartennr.setBounds(579, 256, 100, 20);
  198.         panel.add(txtFKartennr);
  199.         txtFKartennr.setVisible(false);
  200.        
  201.         // Text Area
  202.        
  203.         scrollPane.setBounds(5, 45, 440, 455);
  204.         panel.add(scrollPane);
  205.         scrollPane.setViewportView(textArea);
  206.        
  207.        
  208.         addWindowListener(new meinWindowListener());
  209.        
  210.         /* ist hier mein ...addActionListener(this) richtig platziert?*/
  211.         //----------------------------------------------------------//
  212.         daten_pruefen.addActionListener(this);
  213.         pruefung_abschließen.addActionListener(this);
  214.         //----------------------------------------------------------//
  215.        
  216.         /* Fehlermeldung in den beiden Zeilen: " The method addActionListener(ActionListener)
  217.          * in the typ AbstractButton is not applicable for the arguments (GUI_ATR)
  218.          * */
  219.     }
  220.  
  221.     public class meinWindowListener extends WindowAdapter {
  222.         public void windowClosing(WindowEvent a) {
  223.             System.exit(0);
  224.         }
  225.     }
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement