Ниже приведен код, в котором я создаю JPanel
public class ListBranchesInterface extends JPanel {
private Library theLibrary; // reference to back end
private ArrayList<LibraryBranch> branches;
private DefaultListModel dlm;
private JList list;
private JScrollPane scroll;
public ListBranchesInterface(Library theLibrary) {
this.theLibrary = theLibrary;
branches = new ArrayList<LibraryBranch>();
branches.addAll(theLibrary.getLibraryBranches());
System.out.println(branches.size());
Iterator<LibraryBranch> iter = branches.iterator();
dlm = new DefaultListModel();
while (iter.hasNext()) {
dlm.addElement(iter.next().toString());
System.out.println("Added");
}
list = new JList(dlm); // create a JList from the default list model
scroll = new JScrollPane(list); // add a scroll pane to the JList
add(scroll);
setSize(400, 400);
setVisible(true);
}
}
, когда добавляю панель к JFrame
, ничего не отображается.(Ошибка не в добавлении его к JFrame
, потому что я добавляю другие панели, и они работают правильно.) В чем ошибка?