Java error: cannot find symbol, and can't figure out why

后端 未结 3 630
挽巷
挽巷 2020-12-12 00:51

Error:

error: cannot find symbol

What appears doesn\'t works:

If I write: \"InvoerVakhandler exte

3条回答
  •  时光说笑
    2020-12-12 01:09

    The variable invoervak1 is defined in the boven class and is not visible within InvoerVakHandler. Since InvoerVakHandler is registered exclusively with the invoervak1 component, you can use the source object of your ActionListener to obtain the reference to the JTextField:

    JTextField textField = (JTextField) e.getSource();
    String invoer = textField.getText();
    

    Typically anonymous ActionListener implementations are used. This makes the intended source clear along with its associated functionality.

提交回复
热议问题