JList selected item to String

后端 未结 4 2265
清酒与你
清酒与你 2021-02-19 15:10

Could someone tell me how to get the selected item of JList to a String? It is a single selection JList.

4条回答
  •  误落风尘
    2021-02-19 15:38

    The answers given above doesn't work or are not so advanced as on today. The following code could be used inside the ListSelectionEvent.

    String selected = jList1.getSelectedValue().toString();
    jTextArea1.append("Selected item is  " + selected);
    

提交回复
热议问题