Guest User

Untitled

a guest
Jun 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. package se.mah.negash.dClock;
  2.  
  3.  
  4. import java.awt.BorderLayout;
  5. import java.awt.Color;
  6. import java.awt.EventQueue;
  7.  
  8. import javax.swing.JFrame;
  9. import javax.swing.JPanel;
  10. import javax.swing.border.EmptyBorder;
  11. import javax.swing.JLabel;
  12. import javax.swing.JButton;
  13. import java.util.Calendar;
  14. import java.awt.event.ActionListener;
  15. import java.awt.event.ActionEvent;
  16. import java.awt.Font;
  17.  
  18. public class ClockGUI extends JFrame {
  19. private JLabel watch;
  20. private JButton btnAlarm;
  21. private JPanel contentPane;
  22. private Clock myClock;
  23. private String _hours;
  24. String _minutes;
  25. String time;
  26.  
  27.  
  28. /**
  29. * Launch the application.
  30. */
  31. public static void main(String[] args) {
  32. EventQueue.invokeLater(new Runnable() {
  33. public void run() {
  34. try {
  35. ClockGUI frame = new ClockGUI();
  36. frame.setVisible(true);
  37. } catch (Exception e) {
  38. e.printStackTrace();
  39. }
  40. }
  41. });
  42. }
  43.  
  44. /**
  45. * Create the frame.
  46. */
  47. public ClockGUI() {
  48. myClock = new Clock(ClockGUI.this);
  49. myClock.execute();
  50.  
  51. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  52. setBounds(100, 100, 233, 134);
  53. contentPane = new JPanel();
  54. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  55. setContentPane(contentPane);
  56. contentPane.setLayout(null);
  57. watch = new JLabel();
  58. watch.setFont(new Font("Menlo", Font.PLAIN, 32));
  59. watch.setBounds(67, 6, 94, 58);
  60. contentPane.add(watch);
  61.  
  62. JButton btnAlarm_1 = new JButton("Alarm");
  63. btnAlarm_1.addActionListener(new ActionListener() {
  64. public void actionPerformed(ActionEvent arg0) {
  65.  
  66. myClock.setAlarm(0,1);
  67.  
  68. }
  69. });
  70. btnAlarm_1.setBounds(56, 76, 117, 29);
  71. contentPane.add(btnAlarm_1);
  72. }
  73.  
  74. public void setTime(int hours, int minutes){
  75.  
  76. _hours=Integer.toString(hours);
  77. _minutes=Integer.toString(minutes);
  78. String time = _hours + ":" + _minutes;
  79.  
  80. watch.setText(time);
  81. }
  82. public void setNewBackground(Color c) {
  83. contentPane.setBackground(c);
  84. }
  85. public void invokeAlarm(Color c){
  86. }
  87. }
Add Comment
Please, Sign In to add comment