Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Simple Divition/Multiplication help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Simple Divition/Multiplication help needed" Watch "Simple Divition/Multiplication help needed" New topic
Author

Simple Divition/Multiplication help needed

Jimmy Nilsson
Greenhorn

Joined: Sep 25, 2004
Posts: 26
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
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Jimmy Nilsson
Greenhorn

Joined: Sep 25, 2004
Posts: 26
Thanks, dident notice that with the maximum, ofcourse i shold use that one.

SOLVED!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple Divition/Multiplication help needed
 
Similar Threads
How to scroll tables on both sides of splitpane in sync?
JScrollBar problem???
Moving Scroll Bar in Scroll Pane when new Line added to JTable in ScrollPane
Swing JTable
Identifiers and the <> notation