Search code examples
java-mecontainerstextfieldlwuit

How to make each TextField of a BoxLayout.Y_AXIS have their own width?


There are TextFields , four , contained into a Container whose Layout is BoxLayout(BoxLayout.Y_AXIS). I want each of these TextFields to have their own width. I tried setPreferredW , also setColumns but the TextFields are all the same size which is occupying all the remaining row's width.

So how to make each or some TextFields have their own width visually ?


Solution

  • I found the solution : I derived the TextField class and in the constructor I set the preferred width value.

    PS : I did not call super();