Home > Java > JAVA – Set The Position Of The ScrollBar In JScrollPane()

JAVA – Set The Position Of The ScrollBar In JScrollPane()



The following codes assumes that you have created a JScrollPane() called scrollPane


int x = 0;
int y = 10;

scrollPane.getViewport().setViewPosition(new java.awt.Point(x, y));





In this example x sets the horizontal position of a horizontal scroll bar.
y sets the vertical position of a vertical scroll bar – in this case the vertical scroll bar will appear 10 pixels down from the top.

About these ads
Categories: Java Tags: , , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.