I'm trying to create a popup plugin for IntelliJ. The popup contains a JPanel (parentPanel), which contains a JList (I use JBList which is just a sublcass for Intellij) and JTextField. The contents of the list are built dynamically, depending on the contents of the JTextField when the user presses TAB.
This is what I am currently trying. The result is that a new JList is constructed with the proper elements, but the JPanel stays the exact same size, so most of the JList is obstructed. How can I expand the panel (and the whole popup) so that the entire list is visible?
Am I doing something wrong with JPanel, or is the size constrained by the popup itself?
parentPanel receives GridLayout from this line
this.setLayout(new GridLayout(2,1));
Here is the code which modifies the JList.
DefaultListModel listModel = (DefaultListModel) parentPanel.getFileList().getModel();
listModel.removeAllElements();
VirtualFile[] children = currentPathFile.getChildren();
for(int i = 0; i < children.length; ++i) {
listModel.addElement(children[i].getPath());
}
parentPanel.remove(1); // The list is the panel's second child
parentPanel.add(new JBList(listModel));
parentPanel.revalidate();
parentPanel.repaint();
Even if I give the GridLayout 10 rows, the JList only occupies one row.