Solved

Allign JScrollBar

Posted on 2007-11-27
6
200 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
  • 3
  • 2
6 Comments
 
LVL 24

Expert Comment

by:sciuriware
Comment Utility
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
Comment Utility
0
 
LVL 1

Author Comment

by:Squadless
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 92

Accepted Solution

by:
objects earned 500 total points
Comment Utility
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
Comment Utility
thanks worked to perfection.
0
 
LVL 1

Author Comment

by:Squadless
Comment Utility
wait nevermind, the KNOB of the scroller doesnt move :(
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Java 1603 Error 2 42
topping1 challenge 7 48
PDFBox - convert image to PDF, PDF resolution 3 61
create a gui in perl 3 42
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now