views:

35

answers:

1

I have a a JPanel with a BorderLayout()

BorderLayout.CENTER contains a JComponent which implements scrollable And the north contains a JLabel, when ever I call setText() on the JLabel, the positioning of the JComponent resets back to the default position, of viewing the top left point? Are there methods to get around this, I have had a look in the api but I cannot see anything.

Any help would be much appreciated.

+1  A: 

BorderLayout.CENTER contains a JComponent which implements scrollable

That only has meaning when the compnent is added to a JScrollPane. It has no relevance regarding the layout of a component.

when ever I call setText() on the JLabel, the positioning of the JComponent resets back to the default position

I really have no idea what your program is doing. This probably invokes the layout manager which is putting the component in the proper position. So if this changes position it means it wasn't in the proper position before.

So basically we don't have enough information to provide an answer.

If you need more help post your SSCCE.

camickr
Sorry my mistake, I did not write the JComponent so im not quite sure how it works, There is another class that extends JScrollPane that sets the Jcomponent as its viewPort
James
And you still haven't posted a SSCCE so your question is not any clearer.
camickr