Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package se.mah.negash.dClock;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JLabel;
- import javax.swing.JButton;
- import java.util.Calendar;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import java.awt.Font;
- public class ClockGUI extends JFrame {
- private JLabel watch;
- private JButton btnAlarm;
- private JPanel contentPane;
- private Clock myClock;
- private String _hours;
- String _minutes;
- String time;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- ClockGUI frame = new ClockGUI();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public ClockGUI() {
- myClock = new Clock(ClockGUI.this);
- myClock.execute();
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 233, 134);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
- watch = new JLabel();
- watch.setFont(new Font("Menlo", Font.PLAIN, 32));
- watch.setBounds(67, 6, 94, 58);
- contentPane.add(watch);
- JButton btnAlarm_1 = new JButton("Alarm");
- btnAlarm_1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- myClock.setAlarm(0,1);
- }
- });
- btnAlarm_1.setBounds(56, 76, 117, 29);
- contentPane.add(btnAlarm_1);
- }
- public void setTime(int hours, int minutes){
- _hours=Integer.toString(hours);
- _minutes=Integer.toString(minutes);
- String time = _hours + ":" + _minutes;
- watch.setText(time);
- }
- public void setNewBackground(Color c) {
- contentPane.setBackground(c);
- }
- public void invokeAlarm(Color c){
- }
- }
Add Comment
Please, Sign In to add comment