I have JList, and I want to get the text of the record of this list at a specific index. Can someone tell me how to do this, or do I need to change the structure of the code to getValuesinstead getIndices?
JList
getValues
getIndices
JList dataList=(...) for(int i = 0; i < dataList.getModel().getSize(); i++) { System.out.println(dataList.getModel().getElementAt(i)); }
Object[] temp = jList1.getSelectedValues(); temp[i] = the object you want.
DefaultListModel list = new DefaultListModel(); JList jl = new JList(list); int i = 21; Object = element; String = yourElement; element = jl.getModel().getElementAt(i); yourElement = element.toString;
String nick = jListNicknames.getModel().getElementAt(index).toString(); System.out.println(nick);
Source: https://habr.com/ru/post/1710018/More articles:WPF - IsEnabled DependencyProperty binding not working properly - buttonCreate a registration form so that IE remembers the login information - htmlHow do you structure the database for a wiki site? - wikiWhat is the C interface for Lua to access key / value table pairs? - cMake a sentence from a grammar with a given number of terminals - language-agnosticGeneric SortedList, Как найти индекс первого элемента, который больше, чем ключ поиска? - genericsHow can I read and write to a binary file at the same time? - fileHow many programming languages do you use at one time? - programming-languages | fooobar.comWhy is there no concurrency with Java setAccessible in .NET? - javaGridview RowUpdating event does not fire - eventsAll Articles