So I'm working on a project which needs a JList that prints a different value than what the item says on the list. So when I use the following code:
How would I make it print something like "Adjective Noun Verb" instead of "ANV"? In other words how do I set a value to a particular item besides what it already says? Thanks in advance!Code:String p;
...
class quick1Listener implements ActionListener{
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame("Arrangements");
String[] aras = {"ANV", "NAV", "AVN", "VAN"};
list = new JList(aras);
list.setSelectedIndex(0);
list.setSelectionMode(ListSelectionMo...
list.addListSelectionListener(new listListener());
JButton set = new JButton("Done");
set.addActionListener(new setListener());
frame.getContentPane().add(BorderLayo... list);
frame.getContentPane().add(BorderLayo... set);
frame.setSize(250,250);
frame.setVisible(true);
}
...
class listListener implements ListSelectionListener{
public void valueChanged(ListSelectionEvent e) {
if(!e.getValueIsAdjusting()){
String selection = (String) list.getSelectedValue();
p = selection;
}else{
}
}
}

