Take the 2-minute tour ×

So on my project I have an timer with an label which makes it look like it is Loading so i was wondering how would i make it so there is an % in the middle which after 10 seconds goes to 100% so like 1 second is 10% 1.5seconds is 15%

My Timer

    public void actionPerformed(ActionEvent evt) {



And the Label Code

Loading = new javax.swing.JLabel();

Loading.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pkgnew/launcher/Images/Loading Program/Loading.gif"))); // NOI18N

Loading.setBounds(210, 210, 60, 60);
share|improve this question
In the code where you update the UI with the number, add + "%" to it. If you want specifics, you'll have to show code. –  Jeroen Vannevel Oct 21 '13 at 15:20
Edited the Post –  Christian Harrison Oct 21 '13 at 15:23
add comment

1 Answer

up vote 2 down vote accepted

Making progress bars based of a set time is dangerous as a program which runs in 10 seconds on your PC may take 20 on another due to differing hardware, memory e.t.c. What you may want to look into is a JProgressBar to try and track the progress of whatever you are timing.

Try checking out java2s and Oracle tutorial for a bit more info.

share|improve this answer
Could you link me to a tutorial on this ? –  Christian Harrison Oct 21 '13 at 15:24
Is the bar Customisable tho –  Christian Harrison Oct 21 '13 at 15:28
Did you take the time to read the JProgressBar API? The API has a link to the Swing tutorial. Or did you take the time to search the forum/web using JProgressBar as a keyword. Be proactive. –  camickr Oct 21 '13 at 15:28
add comment

Your Answer


