Hello,
I have a text file which I am reading into a JList. The file is being read in but it is displaying jumbled characters. I would just like to verify that there is nothing I am doing wrong below that would lead to this issue.
try{ // Populate the list box with the descr from the file. FileReader fr = new FileReader(fileName); BufferedReader br = new BufferedReader(fr); Vector<String> lines = new Vector<String>(); String buffer; while ((buffer=br.readLine())!=null){ lines.add(buffer); } JList trackListBox= new JList(lines); JScrollPane tracksScrollPane = new JScrollPane(trackListBox); TitledBorder listBorder = BorderFactory.createTitledBorder("Description"); tracksScrollPane.setBorder(listBorder); add(BorderLayout.CENTER, tracksScrollPane); } catch(Exception e){ e.printStackTrace(); }
Sample Image of what is being displayed.
jumbledtext.png