• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple Divition/Multiplication help needed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey

I have Two JTextPanes that may contain diffrent amopunt of text. To this JTextPane i have JScroolPanes.

I Want the ScroolPanes to be syncroniced and when scroll1 is on location 75% then Scroll2 shold also be on the 75%.

I have problem with doing the math of this, the variabels dont simes to be abled to save fractions?

Code:

double tmpMScrool = scrollbar1.getVerticalScrollBar().getValue();
double tmpMScroolMax = scrollbar1.getVerticalScrollBar().getMaximum();

double ScrollCount = (double)tmpMScrool/(double)tmpMScroolMax;

ScrollCount = (double)scrollbar2.getVerticalScrollBar().getValue() * (double)ScrollCount;

//After this the ScrollCount is 0???

scrollbar2.getVerticalScrollBar().setValue((int)ScrollCount);

What is the problem here?

Best Regards
SnowJim
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not totally sure, but I think that your problem may be that you are using getValue() on scrollbar2, rather than getMaximum().

You certainly don't need most of those casts to "double". They aren't doing anything.
 
Jimmy Nilsson
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, dident notice that with the maximum, ofcourse i shold use that one.

SOLVED!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic