This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.

I'm currenlty delevoping a progress bar for an application with a fixed number of iterations. I have an event listener that monitors the process so I know the current cicle of the process. My problem is when I try to calculate the percentage of the current cicle, relative to the total number of cicles. This is my code:

Fisrt, maybe mention that mon.getCurrentCicle() actually gets the cicles left rather than the current.

So, ciclos is a fixed number and epoca changes every cicle, but when I calculate the percenage with epoca_per it gets stuck at 0.
It's a very simple operation and I've confirmed that epoca actually changes, but I have no clue why epoca_per doesn't change.

Try 100 * epoca / ciclos. The value of epoca must never rise above 21474836 if it is an int.

Why? You are doing integer division: 9999 / 10000 returns 0. If you want to get 99% from 9999 / 10000, you will have to try 100 * 9999 / 10000, which is evaluated as 999900 / 10000, which comes to 99.

Integer division has been messing me up too...I didn't know you can multiply it by another int to get an anwser, I have just been using all doubles up until now!