Title collapse in TitledBorder?

Border s don't directly participate in size evaluation by the LayoutManager (they are not a JComponent themselves but just decorations around a JComponent ) Hence the only way to ensure that the title in a TitledBorder is completely visible is to enfore a minimum size for the panel it is assigned (or rather for components embedded in that panel) Minimum size calculation should in this case be based on the current title of your TitledBorder and the Font used by TitledBorder to paint its title To be honest, I am not sure, all this work is worth writing Based on the exact components comntained inside your TitledBorder a simpler solution would be to use JTextField. SetColumns(n) where n is big enough compared with the title Actually a better way would be to avoid TitledBorder altogether, as suggested by Karsten Lentszch from the JGoodies fame, and replace it with a colored JLabel and a horizontal JSeparator that would fully participate in the layout and hence be used for size computation.

Borders don't directly participate in size evaluation by the LayoutManager (they are not a JComponent themselves but just decorations around a JComponent). Hence the only way to ensure that the title in a TitledBorder is completely visible is to enfore a minimum size for the panel it is assigned (or rather for components embedded in that panel). Minimum size calculation should in this case be based on the current title of your TitledBorder and the Font used by TitledBorder to paint its title.To be honest, I am not sure, all this work is worth writing.

Based on the exact components comntained inside your TitledBorder, a simpler solution would be to use JTextField. SetColumns(n) where n is big enough compared with the title. Actually a better way would be to avoid TitledBorder altogether, as suggested by Karsten Lentszch from the JGoodies fame, and replace it with a colored JLabel and a horizontal JSeparator, that would fully participate in the layout and hence be used for size computation.

Thanx for the information. Let me just try – Rites Apr 21 at 14:11 I Agree with you but who knows may be there is a better way – Rites Apr 21 at 14:21 Yes you're right, see my edit, a recommended way to group components in a panel are to use a JLabel and a JSeparator, rather than a TitledBorder. – jfpoilpret Apr 21 at 14:31 Agree but I'm constrained to use border.

Anyways Thanx for such a useful information and idea :) – Rites Apr 21 at 15:02.

I've got a JPanel with a TitledBorder, but the contents of the panel are narrower than the title in the border and the title gets truncated. I am using BoxLayout for the JPanel which as depicted here pays attention to manual setting of width. I tried to set the minimum, maximum and preferred width of the panel according to the TitledBorder getMinimumSize() function along with the width of its components but all don't work.

The only thing that worked was using a box filler but that introduced an undesired indentation. Any way to the show the full title irrespective to the content it contains?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions