I have mocked up a cut down version that will display the items from first line of any file. There are obviously many things that need to be added in order to provide what you want the code to do. However, without a detailed explanation I am unable to guess what that is, so this is just a starting point:
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.io.*;
class cp extends JFrame
{
public static void main(String[] args)
{
cp cpFrame = new cp();
cpFrame.setData();
}
private void setData() {
this.setSize(400,400);
JPanel panel =new JPanel();
JList list = null;
{
{
list = getList(new File("cp.txt"));
}
}
if (list != null) {
int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
list.setLayoutOrientation(JList.VERTICAL);
JScrollPane jsp6 = new JScrollPane(list, v, h);
this.add(jsp6);
}
this.show();
}
private JList getList(File fr) {
String gg=" ";
DefaultListModel<String> model3=new DefaultListModel<>();
try
{
FileReader fread=new FileReader(fr);
BufferedReader bread=new BufferedReader(fread);
String line=bread.readLine();
char []po=line.toCharArray();
int ih=0;
int pop=0;
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JList<String> kl;
for(ih = 0; ih < line.length(); ih++)
{
gg=" ";
while(po[ih] != '.')
{
gg +=po[ih];
ih++;
}
model3.addElement(gg);
gg=" ";
}
kl=new JList<>(model3);
return kl;
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
return null;
}
}