Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package se.mah.negash.dClock;
- import javax.swing.SwingWorker;
- import java.awt.Color;
- import java.util.Calendar;
- import java.util.List;
- public class Clock extends SwingWorker<Void, Void> {
- ClockGUI clockG;
- private int time_hours;
- private int time_minutes;
- private int alarm_hours;
- private int alarm_minutes;
- String time;
- public Clock(ClockGUI gui){
- clockG=gui;
- }
- @Override
- protected Void doInBackground() throws Exception {
- while(isCancelled() == false)
- {
- System.out.println("Kör tråden");
- this.publish();
- Thread.sleep(1000);
- }
- return null;
- }
- @Override
- protected void process(List<Void> chunks) {
- Calendar myTime = Calendar.getInstance();
- clockG.setTime(myTime.get(Calendar.HOUR_OF_DAY), myTime.get(Calendar.MINUTE));
- }
- public void setAlarm(int hours, int minutes){
- clockG.setNewBackground(new Color(1.0f, 1.0f, 1.0f));
- }
- }
Add Comment
Please, Sign In to add comment