Guest User

Untitled

a guest
Jun 24th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package se.mah.negash.dClock;
  2.  
  3. import javax.swing.SwingWorker;
  4.  
  5. import java.awt.Color;
  6. import java.util.Calendar;
  7. import java.util.List;
  8.  
  9. public class Clock extends SwingWorker<Void, Void> {
  10. ClockGUI clockG;
  11. private int time_hours;
  12. private int time_minutes;
  13. private int alarm_hours;
  14. private int alarm_minutes;
  15. String time;
  16.  
  17. public Clock(ClockGUI gui){
  18. clockG=gui;
  19. }
  20. @Override
  21.  
  22. protected Void doInBackground() throws Exception {
  23.  
  24. while(isCancelled() == false)
  25. {
  26. System.out.println("Kör tråden");
  27. this.publish();
  28. Thread.sleep(1000);
  29. }
  30.  
  31. return null;
  32. }
  33.  
  34.  
  35. @Override
  36. protected void process(List<Void> chunks) {
  37. Calendar myTime = Calendar.getInstance();
  38. clockG.setTime(myTime.get(Calendar.HOUR_OF_DAY), myTime.get(Calendar.MINUTE));
  39. }
  40.  
  41.  
  42. public void setAlarm(int hours, int minutes){
  43. clockG.setNewBackground(new Color(1.0f, 1.0f, 1.0f));
  44.  
  45. }
  46. }
Add Comment
Please, Sign In to add comment