Hi everyone, I'm new here. I have a problem and I hope someone can help me with it. Actually, my problem involves arrays but its about the Gregorian Calendar class. I am trying to output a series of concentric circles . I have created two classes with two different types of patterns. I would like to show one of the two patterns accordingly with the seconds. That is, when the seconds of the clock are even,Bullseye1 pattern shows and when odd, Bullseye pattern shows. I am having problems when trying to refresh the seconds because it is getting the second only once. Another problem is that I don't know how to check the numbers(even) that I put in an array witht the current seconds(integer variable). I hope someone can help. Thanks again.

Thanks stultuske. However I can't understand how to use a thread. I am sorry for my ignorance but I am still learning. Thanks again.

So can someone explain to me how to use a thread please? I am sorry for my arrogance but its pretty urgent since it is for a project I am doing. Mostly i would kie the first problem solved but if someone can slove my second problem, well ,thanks.

If this is a Swing app that needs its GUI refreshed every second then I would advise a Timer rather than doing your own thread. (Either will work, but a timer is less likely to give you problems.)
Have a look at javax.swing.Timer You create one that runs every 1000 mSec. In its actionPerformed you update your clock. Check the standard API doc for details and an example - NB there are 3 timer classes in the API, you need the javax.swing one

Let's get back to the checking odd/even second first. What do you mean by not knowing how to check second? If I remember correctly, GregorianCalendar class has getTimeInMillis() method which return primitive long for getting the time in milli seconds because it extends from Calendar class. Once you get the value, divide by 1000 (and floor the value) and then mod with 2. If it is 0, it is even; otherwise, it is odd. Or am I wrong???

First of all, I would like to thank you James, I have checked and I think you have just solved my first problem. Really thanks. Next, Taywin, well, I actually hadn't thought of that. I think its a brilliant idea. I had actually tried to tackle the problem in a more complicated way by making two arrays one called even and other odd with numbers from 2-58 for even and from 1-59 for odd. Now I realise how complicated that was. Thanks both of you. Now my project is going full steam thanks to you two. Really appreciated.

This question has already been answered. Start a new discussion instead.