Solved

Allign JScrollBar

Posted on 2007-11-27
6
206 Views
Last Modified: 2010-04-21
Hello, my problem is as follows
I have a drop down menu on top and right below is a scroll bar where there are 1000 elements.
the user can either select an element from the drop down menu on top or by scrolling down in the scroll bar and selecting it manually.

the problem is that when the user selects something in the drop down above the scroll bar, the elements get properly highlighted in the scrollbar below BUT the actual SCROLLER does not scroll down to what was selected.

IE: you have a drop down menu of numbers from 1 to 10, you select 6 from the drop down menu, so on the scroll bar you should only see
---
6  (drop down menu where you selected 6)
---
5
6 (highlighted)
7

BUT this is not what happens, what happens is below:
---
6  (drop down menu where you selected 6)
---
1
2
3
---

6 IS highlighted but you have to scroll down to it to see it...

So as you can see the scroll bar doesnt adjust properly based on the selection, how can i maybe set it to always have the selected value be in the middle of the scroll bar?

thanks you
0
Comment
Question by:Squadless
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 24

Expert Comment

by:sciuriware
ID: 20360477
You must make the scrollbar to scroll an item into view.
It depends on the component inside the scrollbar: you must do the work in there.

;JOOP!
0
 
LVL 92

Expert Comment

by:objects
ID: 20361361
0
 
LVL 1

Author Comment

by:Squadless
ID: 20361449
im an idiot, I just realized im using a jscrollpane without a jscrollbar

nonetheless this is what i have

JScrollPane jScrollPane1 = new JScrollPane();
jScrollPane1.setViewportView(plansList);//planlist is JList
jPanel8.add(jScrollPane1, BorderLayout.CENTER);

so i should add a jscrollbar to jscrollpanel and then scrollrecttovisible?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 20361534
u should call scrollrecttovisible visible when you want it to scroll to new selection

u can create your scroller using:

JScrollPane jScrollPane1 = new JScrollPane(plansList);
0
 
LVL 1

Author Closing Comment

by:Squadless
ID: 31411272
thanks worked to perfection.
0
 
LVL 1

Author Comment

by:Squadless
ID: 20361587
wait nevermind, the KNOB of the scroller doesnt move :(
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question