我需要一种简单的方法来实现 JScrollPane,我可以在其中添加 JTextAreas。 这应该像您在 youtube 和 Stackoverflow 上看到的评论系统一样工作。
它应该在 java 代码中,如果有和其他简单的方法我想知道。
List<Comment> comments = businessLogicRepair.getComments(oid, "Internal");
for (Comment comment : comments) {
jInternalCommentScrollPane.add(new JTextArea(comment.getText()));
}
我的评论对象包含:
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;
}
我将评论保存在数据库中,我可以轻松获取它们。问题是显示部分。
感谢帮助
最佳答案
你必须接受只放一个 JComponent 是可能的到 JScrollPane ,在你的情况下只有一个 JTextArea
关于java - 具有多个 JTextAreas 的 JScrollPane,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7818387/