java - How can I change the size of a JPanel to fit a dynamically generated JBList? -


i'm trying create popup plugin intellij. popup contains jpanel (parentpanel), contains jlist (i use jblist sublcass intellij) , jtextfield. contents of list built dynamically, depending on contents of jtextfield when user presses tab.

this trying. result new jlist constructed proper elements, jpanel stays exact same size, of jlist obstructed. how can expand panel (and whole popup) entire list visible?

am doing wrong jpanel, or size constrained popup itself?

parentpanel receives gridlayout line

this.setlayout(new gridlayout(2,1)); 

here code modifies jlist.

defaultlistmodel listmodel = (defaultlistmodel) parentpanel.getfilelist().getmodel(); listmodel.removeallelements(); virtualfile[] children = currentpathfile.getchildren();  for(int = 0; < children.length; ++i) {    listmodel.addelement(children[i].getpath()); } parentpanel.remove(1); // list panel's second child parentpanel.add(new jblist(listmodel)); parentpanel.revalidate(); parentpanel.repaint(); 

even if give gridlayout 10 rows, jlist occupies 1 row. enter image description here

if parentpanel jpanel, default layout flowlayout, retains initial preferred size, typically defined preferred size of original content. try changing gridlayout, allow list grow , shrink enclosing panel resized.

that doesn't work either. gridlayout code has been added.

because jblist extends jlist, may able use setvisiblerowcount(), shown here.


Comments