I am attempting to display an array
of strings
in a JList
, which is then added to a JPanel
using Java Swing
. I am not having a problem displaying the data in the Jlists
, however I would like to remove the default property that allows a user to select items in the Jlist
. I am attempting to simply display the data to the user. Unfortunately I am unable to locate the property that would allow me to disable this feature. A example of the selection property that I am referring to can be seen here in 1.
Perhaps I am using the wrong Java Swing
component to display this data, but I have research JTextArea
, JTable
, etc., and the JList
seems to fit my needs. Any help is much appreciated.
public static JComponent createList(ArrayList inputData) {
JPanel panel = new JPanel(false);
panel.setLayout(new FlowLayout(FlowLayout.LEFT));
panel.setBackground(Color.white);
String[] displayData= {Data.get(0),Data.get(1),Data.get(2),Data.get(3)};
JList<String> displayDataList= new JList<String>(displayData);
displayDataList.setFont(sysDataList.getFont().deriveFont(Font.PLAIN));
panel.add(displayDataList);
return panel;
}