I am attempting to put a JGoodies panel into a JScrollPane with only a vertical scroll bar; any elements larger than the current JScrollPane width should be truncated. However I can't figure out a way to make this work
Example of the effect I'm going for
What I don't want to happen
My current code is essentially:
FormLayout locationsLayout = new FormLayout("15dlu, pref, 5dlu, pref, 5dlu, pref:grow", "");
locationsBuilder = new DefaultFormBuilder(locationsLayout)
.background(Color.WHITE)
.lineGapSize(Sizes.ZERO);
locationsPane = new JScrollPane(locationsBuilder.getPanel());
locationsPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
locationsPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
//...Sometime later, the user adds a folder...
FormLayout headerLayout = new FormLayout("pref, pref", "pref");
DefaultFormBuilder headerBuilder = new DefaultFormBuilder(headerLayout)
.background(Color.WHITE)
.lineGapSize(Sizes.ZERO);
headerBuilder.add(curContainer.getGuiHeader(), CC.xy(1, 1));
headerBuilder.add(curContainer.getGuiTablePrefix(), CC.xy(2, 1));
locationsBuilder.leadingColumnOffset(0);
locationsBuilder.append(headerBuilder.getPanel(), 6);
Things I've tried
I don't know what else I can try. Does anybody have any suggestions?
I never could find an exact answer to this specific setup. My guess is that JGoodies dies bit handle nested layouts very well.
I ended up "fixing" this by using only one single panel for the entire locations scroll pane. This made the layout a bit complicated: Multiple cells now had to span columns and I had to manually adjust the column offset. But in the end it works