I did a program that connecting to database then show data and user can ( add or remove or update ) data but my problem that program take a little time to be ready how i can know that time and make notification for user to use program now or wait (Program still in loading)

Recommended Answers

All 8 Replies

long start = System.currentTimeMillis();
long end = 0l;
long elapsed = 0l;

// your code

end = System.currentTimeMillis();
elapsed = end - start;
System.out.println(("Search Spent " + ((int) (elapsed / 1000)) + " seconds");

but some Java Gurus told that System.nanoTime(); is more precious

thnx but i do my program using swing controllers and jframeform where i can but this code to calculate all the program time that need to be ready

what you really needed

1) calculate time between two periods,
2) pre-calculate required time and to display that in JProgressBar
3) or entertain the audience (in some way) during the the program works, rotated Icon, change Cursor, diplay some notice...

Number 2
pre-calculate required time and to display that in JProgressBar

read about call back in java swing

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.