Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Custom JScrollPane - Double JScrollBars

Reply
Thread Tools

Custom JScrollPane - Double JScrollBars

 
 
Roedy Green
Guest
Posts: n/a
 
      05-01-2008
On Tue, 22 Apr 2008 21:15:07 -0700 (PDT), pek <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>Is there any way I can customize a JScrollPane and instead of one
>horizontal JScrollPane it would show two? Can you point me somewhere?


It strikes me as an odd thing to do given how precious screen real
estate is.

I would study the code for JScrollPane and related classes in src.zip.
You could then base your class overriding just what you need, or
building one from scratch without any special features.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
 
 
 
pek
Guest
Posts: n/a
 
      05-08-2008
On May 1, 6:08 pm, "Larry A Barowski"
<ThisisLarrybarAtEngDotAuburnDotLearninginstitutio n> wrote:
> "pek" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
> > On Apr 29, 5:07 pm, "David A. Redick" <(E-Mail Removed)>
> > By the way, there is a little problem. I'm running Linux, and when the
> > knob is being dragged, it moves the view perfectly. But if let's say,
> > I drag the knob from the middle to 1/3 position and just hold the knob
> > there, the view doesn't move. As long as the knob is being dragged it
> > does. I hope you understand what I'm saying.

>
> Something like this should work:
>
> private Timer horizTimer = new Timer(250,
> new ActionListener() {
> public void actionPerformed(ActionEvent ev) {
> int iDir = m_pHSB2.getDir();
> int iInc = horizontalScrollBar.getUnitIncrement(iDir);
> int iSpeed = m_pHSB2.getSpeed();
> iInc *= iSpeed;
> int iValue = horizontalScrollBar.getValue();
> iValue += iDir*iInc;
> horizontalScrollBar.setValue(iValue);
> }
> });
>
> private Timer vertTimer = new Timer(250,
> new ActionListener() {
> public void actionPerformed(ActionEvent ev) {
> int iDir = m_pVSB2.getDir();
> int iInc = verticalScrollBar.getUnitIncrement(iDir);
> int iSpeed = m_pVSB2.getSpeed();
> iInc *= iSpeed;
> int iValue = verticalScrollBar.getValue();
> iValue += iDir*iInc;
> verticalScrollBar.setValue(iValue);
> }
> });
>
> public void adjustmentValueChanged(final AdjustmentEvent e)
> {
> SpringyScrollBar p = (SpringyScrollBar) e.getAdjustable();
> boolean bIsHoriz = p.equals(m_pHSB2);
> Timer timer = bIsHoriz? horizTimer : vertTimer;
> if(!e.getValueIsAdjusting())
> {
> // move back to center
> timer.stop();
> p.moveToMid();
> }
> else {
> if (p.getSpeed() != 0 && !timer.isRunning()) {
> timer.start();
> }
> }
> }


Thanks to this code and the one provided by the others, I finally
created exactly what I wanted. I did some changes (such as setting
speed, enable/disable springyscrollbar etc.) and I'm ready to post it
but there is one small problem. I'm trying to follow as much
"principles" as the JScrollPane has, so, I didn't forced
verticalScrollBarPolicy to ALWAYS but left it for the user to decide.
Well, the default vertical and horizontal scrollbars have each a
policy of their own. What about the springyscrollbars? How do I
implement a policy? The source code of JScrollPane doesn't indicate
anywhere where the policies are used, or more likely, *I* didn't find
any such indication. Any suggestions on how to implement policies for
the springyscrollbars?

Thank you again.
 
Reply With Quote
 
 
 
 
Jeff Higgins
Guest
Posts: n/a
 
      05-08-2008

pek wrote:
> Well, the default vertical and horizontal scrollbars have each a
> policy of their own. What about the springyscrollbars? How do I
> implement a policy? The source code of JScrollPane doesn't indicate
> anywhere where the policies are used, or more likely, *I* didn't find
> any such indication. Any suggestions on how to implement policies for
> the springyscrollbars?
>


int HSSBPolicy
int VSSBPolicy

get/set SSBPolicies

DoubleScrollPaneLayout


 
Reply With Quote
 
pek
Guest
Posts: n/a
 
      05-15-2008
On May 9, 1:32 am, "Jeff Higgins" <(E-Mail Removed)> wrote:
> pek wrote:
> > Well, the default vertical and horizontal scrollbars have each a
> > policy of their own. What about the springyscrollbars? How do I
> > implement a policy? The source code of JScrollPane doesn't indicate
> > anywhere where the policies are used, or more likely, *I* didn't find
> > any such indication. Any suggestions on how to implement policies for
> > the springyscrollbars?

>
> int HSSBPolicy
> int VSSBPolicy
>
> get/set SSBPolicies
>
> DoubleScrollPaneLayout


Nope, nothing worked. I used the same JScrollPaneConstants for the
policy in the DoubleScrollPane, but nothing changed. I copied the code
that JScrollPane uses from the source code. It is almost the same
thing, but nothing happens. But when I set the
horizontalScrollBarPolicy (not the springy one) it works for both!
Probably because I use the same JScrollPaneConstants, but then again,
how else can I implement this?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Custom JScrollPane - Double JScrollBars pek Java 0 05-15-2008 04:16 PM
[Swing] JScrollPane double MouseMotionListener oliv@linuxmail.org Java 1 03-11-2007 04:47 PM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM
Custom paint in JScrollPane Thomas Richter Java 12 11-13-2004 11:50 AM
JScrollPane scroll to top Richard Trahan Java 0 07-26-2003 04:01 PM



Advertisments