JScrollPane有多个JTextAreas

1 java swing comments jscrollpane jtextarea

我需要一种简单的方法来实现JScrollPane,我可以在其中添加JTextAreas.这应该像评论系统一样工作,就像你在youtube上看到的那样,在这里就是Stackoverflow.

它应该是在java代码中,如果theres和其他简单的方式,我想知道它.

List<Comment> comments = businessLogicRepair.getComments(oid, "Internal");

        for (Comment comment : comments) {
            jInternalCommentScrollPane.add(new JTextArea(comment.getText()));

        }
Run Code Online (Sandbox Code Playgroud)

我的评论对象包含:

public Comment(String id, String type, String text, String author, String postDate, String repairId) {
    super(id);
    this.type = type;
    this.text = text;
    this.author = author;
    this.postDate = postDate;
    this.repairId = repairId;
}
Run Code Online (Sandbox Code Playgroud)

我将评论保存在数据库中,我可以轻松搞定.问题是显示部分.

谢谢您的帮助

mKo*_*bel 5

你必须接受可以只将一个JComponent放到JScrollPane,在你的情况下只有一个JTextArea