Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JScrollPane align

Status
Not open for further replies.

MagiMike

Technical User
Jun 5, 2003
44
SE
I have a JPanel inside a JScrollPane. When I oversize the window so that the JScrollPane area is larger than the JPanel then the JPanel gets centered inside the JScrollPane area.
However I'd rather have it aligned to the upperleft corner of the JScrollPane area. How do I make JScrollPane do that?

/ Mike Morrison
 
Panel.setHorizontalAlignment(JPanel.LEFT);
Panel.setVerticalAlignment(JPanel.TOP);

I've never actually tried to do it, but this is how you do it with a label. So I'm guessing a panel would be the same way. Replace the word Panel with your JPanel name. You have to do this before you add them to the panel. If you resize you may need to redraw with the alignment, but I don't believe so.

Amos
Computer Science
U of MO - Rolla
 
Unfortunately JPanel doesn't have those methods :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top