So I need to be able to scroll in my frame. I have a queues management application using threads and everytime the simulation time change I call the method addTextArea from the run method of a thread to add information to the frame : the time, waiting clients and queues with the clients. But I have to be able to scroll in the frame. I tried to use a container but nothing shows up. can someone please help me? I am new at java and GUI and UI. Thank you!
package GUI;
import java.awt.*;
import java.io.FileWriter;
import java.io.IOException;
 
import org.example.Client;
import org.example.Coada;
import javax.swing.*;
import java.util.List;
public class TableFrame extends JLabel {
    private JPanel panel = new JPanel();
    private  JFrame frame = new JFrame();
    private static JScrollPane scrollPane = new JScrollPane();
    private Container container = new Container();
    public TableFrame(){
        frame.setTitle("Log of events");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setResizable(false);
        panel.setSize(500,500);
        frame.setSize(500,500);
        frame.setVisible(true);
 
        Container container = new Container();
        container.setLayout(new BorderLayout());
        container.add(panel,BorderLayout.CENTER);
        scrollPane= new JScrollPane(container);
        frame.getContentPane().add(scrollPane);
    }
 
    public void addTextArea(int nr_queues, int time, List<Client> waitingClients, List<Coada> queues){
        JTextArea area = new JTextArea(nr_queues,500);
        area.setEditable(false);
 
        area.append("Time: " + time + "\n");
        area.append("Waiting clients: ");
        for(int i=0;i<waitingClients.size();i++){
            area.append("(" + waitingClients.get(i).getId() + "," + waitingClients.get(i).getArrivalTime() + "," + waitingClients.get(i).getServiceTime() + ");");
        }
        area.append("\n");
 
        for(int i=0;i<queues.size();i++){ //parcurg lista cu cozi
            int j=i+1;
            area.append("Queue " + j + ": ");
            if(queues.get(i).getNrClientiDinCoada() == 0){ //daca size la lista de clientii a cozii = 0 => closed
                area.append("closed\n");
            }
            else{ //daca size la lista de clienti a cozii !=0 => parcurgem lista de clienti a cozii si scriem clientii
                int sizeCoadaActuala = queues.get(i).getNrClientiDinCoada();
                for(int k=0;k<sizeCoadaActuala;k++){
                    area.append("("+queues.get(i).getListClienti().get(k).getId()+ "," + queues.get(i).getListClienti().get(k).getArrivalTime() + "," + queues.get(i).getListClienti().get(k).getServiceTime() + ");");
                }
                area.append("\n");
            }
 
        }
 
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));//
        panel.add(area);//
        frame.setContentPane(panel);//
        frame.pack();//
        frame.setVisible(true);//
 
        try {
            FileWriter myWriter = new FileWriter("log.txt", true);
            myWriter.write(area.getText());
            myWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
 
    }
}