1

My friend is facing an issue where in he has a Swing Dialog and it has several text fields, combo boxes and radio buttons. Also it has a JPanel which holds the search results if at all the user wants to perform any search.

It looks fine with normal font size. But once the font size is increased to say 150% or even 200%, then the text boxes are not growing and the text in them is growing. So, they are not fitting in and are getting clip-ed.

He managed to overcome this limitation by using the setPreferredSize method on the UI components. Now it seems that he is able to control the behaviour in case of text boxes, combo boxes etc. But the search panel is still an issue.

Could some one please point out what the issue could be?

UPDATE: They also have a JTable where the search results are displayed. Now, the thing is, they are hardcoding the height of each row in that JTable using the call setRowHeight. And due to this, if the font size is increased, the row height still remains the same. Is there any method call that resolves this. We honestly think that they should not have done that hardcoding. Is there any solution for this? Please share.

Thanks, Pavan.

Pavan Dittakavi
  • 3,013
  • 5
  • 27
  • 47
  • Is there just JPanel? or textbox / label? I assume you cannot write inside JPanel itself. – nebula Dec 09 '11 at 08:29
  • The search results seems to be displayed there. The searching is being done at the top. – Pavan Dittakavi Dec 09 '11 at 08:45
  • DO NOT USE setXXSize - that's part of the problem, not of a solution http://stackoverflow.com/questions/7229226/should-i-avoid-the-use-of-setpreferredmaximumminimumsize-methods-in-java-swi The real problem most probably is that you are not using LayoutManagers ... – kleopatra Dec 09 '11 at 10:02

2 Answers2

1

Which layout is your friend using? Choosing a suitable layout may help.

xorange
  • 191
  • 1
  • 10
1

Try pack() it will automatically adjust the Window to fit the preferred size of the components.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
nebula
  • 3,932
  • 13
  • 53
  • 82