2017-04-12 28 views
0

我已經寫了一個方法來控制好類的所有按鈕:集團是ActionEvent到一個類

public void buttonController(JButton buttonStimmeErfassen, JButton buttonProjekteLaden, JButton buttonDBimport, JButton buttonErfasserSpeichern, ActionEvent e) { 
    if (e.getSource().equals(buttonStimmeErfassen)) { 
     new TabController().tabWechseln(1,e); 
    } else if (e.getSource().equals(buttonProjekteLaden)){ 
     new TabController().tabWechseln(2,e); 
    } else if (e.getSource().equals(buttonDBimport)){ 
     new TabController().tabWechseln(3,e); 
    } else if(e.getSource().equals(buttonErfasserSpeichern)); { 
     new StartTabModel().erfasserSpeichern(StartTab.textfeldErfasser,buttonErfasserSpeichern,e,frame); 
    } 
} 

的按鈕被稱爲在我看來類:

public void actionPerformed(ActionEvent e) { 
     // TODO Auto-generated method stub 
     e.getActionCommand(); 
     new StartTabModel().buttonController(buttonStimmeErfassen, buttonProjekteLaden, buttonDBimport, buttonErfasserSpeichern, e); 
    } 

它的工作原理至今。但我有另一種方法,如果我觸發任何按鈕,最後一個方法總是被調用。

public void erfasserSpeichern(JTextField j, JButton b, ActionEvent a, JInternalFrame frame) { 

     if (j.isEditable() == true) { 
     a.getActionCommand(); 
     j.setEditable(false); 
     b.setText("Logout"); 

     if (j.getText().equals("S119")) { 
      JOptionPane.showMessageDialog(frame, "xxx"); 
      j.setEditable(true); 
      b.setText("Login"); 
     } else 
      JOptionPane.showMessageDialog(frame, "xxx"); 

    } else if (j.isEditable() == false) { 
     a.getActionCommand(); 
     j.setEditable(true); 
     b.setText("Login"); 
     JOptionPane.showMessageDialog(frame, "xxx"); 
     j.setText("S119"); 
    } 

任何人都可以解釋我做錯了什麼?

回答

0

我找到了解決辦法...愚蠢的錯誤...... 有一個分號我否則,如果:

else if(e.getSource().equals(buttonErfasserSpeichern));