Reputation: 591
I'm currently implementing a ordered search for one of our apps.
In order to left space for the data, especially in landscape orientation, I've moved my previous ordering components in a Dialog. In order to order the data, I use one String Picker to select the field on which my SQL will order the data on server side and a button to select ASC/DESC.
The components are working fine, my search is good, but the problem lies here: The Dialog is too small, and my picker is so shrinked that if the first selected string is smaller than the others, the larger strings will not be shown completely.
Default String Selected, no problem.
Larger String Selected, the picker is too small.
The layout of the dialog's content pane is a BorderLayout with a Label on the left, the picker in the center and a button on the right.
Is it a way to force the picker to autoset it's width to the width of it's longest String ? Or anything else in order to show the complete string in my picker ?
Thanks in advance !
Upvotes: 0
Views: 83
Reputation: 52760
There are two workarounds I can think of:
Button longestString = new Button("Set longest String here");
Component.setSameWidth(longestString, myPicker);
The alternative is to grow/shrink the dialog on selection:
myPicker.addActionListener(e -> myDialog.growOrShrink());
Upvotes: 1