Simple Mathematics.
-
Why is it giving me a zero.
double percent = 0;
if(condition) {
//scrollpane is a JScrollPane and origIcon is a ImageIcon
percent = scrollpane.getHeight() / origIcon.getImage().getHeight(scrollpane);
System.out.print(scrollpane.getHeight() + " / " + origIcon.getImage().getHeight(scrollpane));
System.out.println(" = " + percent);
} else {
//line of codes
}This returns
309 / 1668 = 0.0
value should be0.1852..
I know this is basic but I DON'T KNOW. sorry, too tired I guess but I need this to figure out Thanks- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind. - Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
-
Why is it giving me a zero.
double percent = 0;
if(condition) {
//scrollpane is a JScrollPane and origIcon is a ImageIcon
percent = scrollpane.getHeight() / origIcon.getImage().getHeight(scrollpane);
System.out.print(scrollpane.getHeight() + " / " + origIcon.getImage().getHeight(scrollpane));
System.out.println(" = " + percent);
} else {
//line of codes
}This returns
309 / 1668 = 0.0
value should be0.1852..
I know this is basic but I DON'T KNOW. sorry, too tired I guess but I need this to figure out Thanks- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind. - Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
Because that's what
scrollpane.getHeight() / origIcon.getImage().getHeight(scrollpane)
returns, due to integer datatypes. I don't know Java, but I expect you could do something like:percent = scrollpane.getHeight();
percent = percent / origIcon.getImage().getHeight(scrollpane); -
Because that's what
scrollpane.getHeight() / origIcon.getImage().getHeight(scrollpane)
returns, due to integer datatypes. I don't know Java, but I expect you could do something like:percent = scrollpane.getHeight();
percent = percent / origIcon.getImage().getHeight(scrollpane);well that gives me an idea.. casting should do the trick Thanks
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind. - Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
-
well that gives me an idea.. casting should do the trick Thanks
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind. - Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
Yes, if done right.
-
Yes, if done right.
thank you very much it works :zzz:
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind. - Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.