Problem with reusing the JScrollPane again for different custom Lists

前端 未结 2 1948
你的背包
你的背包 2020-12-22 02:03

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

2条回答
  •  执笔经年
    2020-12-22 03:06

    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.

提交回复
热议问题