0

I wrote a Java program that reads a file, process the numbers and then output result to to the user. The processing could take a while so I would like to display some sort of progress bar or just simply thinking glass (anything reallly) that indicate to the user that the program is actually processing something.

Any recommendation for quick Solution for it?

Thank you

Snake
  • 14,228
  • 27
  • 117
  • 250

2 Answers2

1

Display a busy cursor:

try {
  component.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
  // process
} finally {
 component.setCursor(Cursor.getDefaultCursor());
}
sina72
  • 4,931
  • 3
  • 35
  • 36
0

This might help you...

Command line progressbar

http://nakkaya.com/2009/11/08/command-line-progress-bar/

public static void printProgBar(int percent){
    StringBuilder bar = new StringBuilder("[");

    for(int i = 0; i < 50; i++){
        if( i < (percent/2)){
            bar.append("=");
        }else if( i == (percent/2)){
            bar.append(">");
        }else{
            bar.append(" ");
        }
    }

    bar.append("]   " + percent + "%     ");
    System.out.print("\r" + bar.toString());
}
Paresh Radadiya
  • 185
  • 4
  • 10
  • Although this would answer the question, you should add some of the content from that link to your answer. Just in case the link gets unaccesible or someother thing. – Afzaal Ahmad Zeeshan Jun 30 '14 at 15:18