Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default Help me with digital clock

    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    public class ClockWriter extends JPanel
    { public ClockWriter ()
    { int width = 200;
    JFrame clock = new JFrame();
    clock.getContentPane().add(this);
    clock.setTitle("Clock");
    clock.setSize (width, width);
    clock.setVisible(true);
    }
    public void paintComponent(Graphics g)
    { int width = 200;
    g.setColor(Color.red);
    g.fillRect(0,0,width,width);
    GregorianCalendar time = new GregorianCalendar();
    int minutesAngle = 90 - (time.get(Calendar.MINUTE)*6);
    int hoursAngle = 90 - (time.get(Calendar.HOUR)*30);
    int secondsAngle = 90 - (time.get(Calendar.SECOND)*6);
    int leftedge = 60;
    int top = 40;
    int diameter = 100;
    g.setColor(Color.white);
    g.drawOval(leftedge, top,diameter , 2 * diameter);
    g.setColor(Color.black);
    g.fillArc(leftedge + 5, top + 5, diameter - 10, diameter - 10, minutesAngle,5);
    g.setColor(Color.blue);
    g.fillArc(leftedge + 10, top + 10, diameter - 10, diameter - 10, hoursAngle, -8);
    g.setColor(Color.white);
    g.fillArc(leftedge, top, diameter, diameter, secondsAngle,5);
    this.repaint();
    }
    public static void main(String[] a)
    { new ClockWriter();
    }
    }


    (this is Clock , i have to do digital one , sombody help me how to do it .... )

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Help me with digital clock

    Please wrap your posted code in [code] [/code] tags so that it retains its formatting. Please ask an answerable question including letting us know what is wrong with your current code and where exactly you're stuck. Else we will not know how to help you.

  3. #3
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default Re: Help me with digital clock

    i have to do a Digital Clock , not Classic Clock ... undestandd ??

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: Help me with digital clock

    So where are you stuck?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: Help me with digital clock

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Help me with digital clock

    Quote Originally Posted by EdisjanSadikaj View Post
    i have to do a Digital Clock , not Classic Clock ... undestandd ??
    You are telling us what you need not where you're stuck. Please understand that no one is going to do this assignment for you, and if you don't ask a decent question, no one will be able to help you. Please read Writing the perfect question - Jon Skeet: Coding Blog

Similar Threads

  1. 24 hour clock to 12 hour clock project.
    By bs3ac in forum New To Java
    Replies: 4
    Last Post: 01-08-2013, 10:10 AM
  2. digital sign libraries
    By Shuru in forum Advanced Java
    Replies: 4
    Last Post: 11-07-2008, 08:01 AM
  3. Help please in digital clock
    By jaidod in forum Java Applets
    Replies: 1
    Last Post: 04-17-2008, 04:05 PM
  4. need help print random digital
    By lowpro in forum New To Java
    Replies: 1
    Last Post: 12-31-2007, 06:47 AM
  5. need help print char and digital
    By lowpro in forum New To Java
    Replies: 4
    Last Post: 12-04-2007, 07:20 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •