Menu
To develop a Android Application that creates Alarm Clock. Procedure: Creating a New project: Open Android Studio and then click on File -> New -> New project. Then type the Application name as “ex.no.11″ and click Next. Then select the Minimum SDK as shown below and click Next. Then select the Empty Activity and click Next.
JAVA Programming Please have the program to have user input to set the alarm for the watch and wind the clock for the pendulum clock. Please I need help. Please have the program to have user input for digital clock to set the time. Please have the program to allow user input for each of the classes. Write a program with the following requirements and conditions: In your program you're supposed to be able to create different kind of clocks. You will need a base class called Clock. This class should have a parameter (or parameters) to save the current time.
This object should also have a function called displayCurrentTime. When this function is called, it should output the current time to the console. The class also should have a String parameter called “ Make”. Next, you will create three subclasses that inherit from Clock, those three classes are: Watch, PendulumClock, and DigitalClock. The Watch class should have a private parameter called alarm, which can hold a specific time to save an alarm. It also should provide a public get and set function for this parameter.
The PendulumClock should have a function called windUp. When this function is called, it should set an internal parameter to currentTime + 24h. When the user requests the time from a PendulumClock, only if the 24h haven't passed since the last wind-up, the current time should be displayed, otherwise a message should be output that says: “ Please wind up the clock.” (hint: you will need to override the function from the base class) The DigitalClock should be able to be manually set. That means it should have a function called setTime, which will set the time to whatever the user inputs and passes to the function, and when asked again what the current time is it should accurately keep track of timekeeping based on the new time set.
(hint: you might want to save the time difference in a private property if the time is manually set, so anytime the time is requested, you will know how to calculate the difference from the current time upon request) Extra Credit: Create and submit another UML Diagram for Exercise 2 (+10 points).
The part that I don't understand are the action listeners. I've managed to get a java.util.timer to update the jLabel, but you said that's wrong so I'm trying to understand the javax.swing.timer. An action listener is a class that implements java.awt.event.ActionListener and has a actionPerformed(java.awt.event.ActionEvent e) method.
This should work for you just as well as when you created a TimerTask for java.util.Timer, and it is even better for Swing because it will run in the event dispatch thread which makes it safe. The only part that might be tricky is that ActionListeners can listen to things other than timers. I recommend that you create a special ActionListener just for your timer instead of reusing an ActionListener that you have listening to other things. If for any reason you are unable to understand ActionListener then you can get the same thread safety by calling javax.swing.SwingUtilities.invokeLater(Runnable doRun) inside the run method of your TimerTask, with doRun being a Runnable that does what you really want the timer to do. You can use invokeLater in any situation to do something on the event dispatch thread, with the down-side being that it won't happen until sometime after you call invokeLater. You can also use invokeAndWait which blocks until the thing you want to do is actually done, but there's no reason to do a thing like that for a timer and it is more complicated than invokeLater.