mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.24k stars 243 forks source link

[Question] set max width for an ActionListBox instead of setPrefferedSize? #479

Closed AObuchow closed 4 years ago

AObuchow commented 4 years ago

Hey, I'm trying to figure out how to set the max-width of an ActionListBox (but have its length not be limited). setPrefferedSize almost accomplishes what I want, but it doesn't let the component grow past the preferredSize.

Currently, I'm using a GridLayout with multiple action list boxes. Each action list box is populated with files for a given directory. The length of the filenames is variable, so the action list box will grow in width to accommodate a longer filename. I'd like to set a limit to how much each action list box can grow in width.

Here's a gif of the current behavior (I'm basically building a Norton Commander clone): Current behavior

The desired behavior would be that the width sizing remains constant, as seen in this gif of Ranger: Desired behavior

Is there a way to accomplish these using layouts/Lanterna API? Maybe I shouldn't be using GridLayout?

Thanks :) & sorry for the very specific question.

AObuchow commented 4 years ago

Sorry for the broken gifs I attached. Will fix them shortly.

AObuchow commented 4 years ago

Sorry for the broken gifs I attached. Will fix them shortly.

The gifs should be visible now.

AObuchow commented 4 years ago

...I solved my issue!

Turns out to get the behavior I wanted, I had to use a BorderLayout (and set preffered sizes) instead of a GridLayout for the ActionListBoxes.