I am trying to create a JScrollPane component which can be reused depending upon the string parameter that is being passed.. I have created the following code, it works if I
public class ListComponent extends JScrollPane
What? You should not be extending a JScrollPane. You are not adding new functionality to the scroll pane.
If you are trying to add a JList to a JScrollPane, then I suggest you read the JList API and follow the link to the Swing tutorial on "How to Use Lists" for a working example.