Get String from another method

后端 未结 1 1430
长发绾君心
长发绾君心 2021-01-29 12:13

I have 2 methods, the first one where i display selected value, index from my JList(list). What i want to do is to send selectedValue - s - to CreateMap method. I tried this cod

1条回答
  •  一生所求
    2021-01-29 13:00

    I assume you have 2 String variables called s, one global and one local in actionPerformed.

    Change the line

    String s = (String) list.getSelectedValue();
    

    to

    this.s = (String) list.getSelectedValue();
    

    And it should work. Be sure you have a global variable called String s.

    0 讨论(0)
提交回复
热议问题