Wednesday, December 11, 2019

Timer

Found the perfect code to see the functionning of the Swing
utility timer. It is a clock:


Ran it through Eclipse and added some color.
 _timeField.setBackground(new Color(28, 65, 130));
 _timeField.setForeground(Color.LIGHT_GRAY);


 JPanel content = new JPanel();
 content.setBackground(Color.PINK);

Even added an image to it.

ImageIcon icon = new ImageIcon("C:/users/Louise/Desktop/NewLOR.png");
JLabel label = new JLabel(icon);
this.add(label);



The sleep code delays things for one minute. As it is in the body of the code, it
serves to delay the start of the window by one minute. What would be cool would be for the
clock to run for a minute, and then have the image appear.

Need to start a different thread!?

TimeUnit.MINUTES.sleep(1);

http://www.fredosaurus.com/notes-java/examples/animation/41TextClock/25textclock.html

                                                      *     *     *

My image now appears from the main method. Need to put
a scheduler on it!!


Success:


*     *     *
I now reference the image form Eclipse. I created a source folder in 
the project called Images and transferred the image in it. If I
drag and drop the image in the parenthesis, the path address will
appear.





No comments: