Question

I have a class which extends JPanel, but it is not working. Would someone tell me how can I solve the issue. It looks like the error is on "super";

This is my class:

public class DivCommentJPane extends JPanel  {

private BeanPanel thisBean;
private CommentItem thisComment; 
private String pageErrorPrefix="Error On DivCommentJPane.java : "; 
private PDFNotesBean bean;


public DivCommentJPane(CommentItem comment ){
    //thisBean=bean;
    super();
    thisComment=comment;
    setting();



}

The code below is to add DivCommentJPane into another JPane:

ArrayList<CommentItem>sortComment= lstComment;
         Collections.sort(sortComment,CommentItem.sortPage);
         for(CommentItem comm: sortComment){
             DivCommentJPane d=new DivCommentJPane(comm);
             listCommentPane.add(d, BorderLayout.CENTER);
         }
Was it helpful?

Solution

Since you are using a BorderLayout, "[e]ach region may contain no more than one component."

Therefore repeated attempts to add to the CENTER region (listCommentPane.add(d, BorderLayout.CENTER); ) will end up replacing what was previously there.

You will have to use a different layout manage instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top