Results 1 to 6 of 6
Thread: Help me with digital clock
- 12-18-2012, 10:42 PM #1
Member
- Join Date
- Dec 2012
- Posts
- 2
- Rep Power
- 0
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 .... )
-
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.
- 12-19-2012, 01:57 AM #3
Member
- Join Date
- Dec 2012
- Posts
- 2
- Rep Power
- 0
Re: Help me with digital clock
i have to do a Digital Clock , not Classic Clock ... undestandd ??
- 12-19-2012, 02:52 AM #4
Re: Help me with digital clock
So where are you stuck?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-19-2012, 02:57 AM #5
Re: Help me with digital clock
Code from
http://people.cis.ksu.edu/~schmidt/CIS200/ch4V12.html (about 40% down tha page)
or http://people.cis.ksu.edu/~schmidt/PPJv12pdf/ch4V12.pdf (page 128)
or one of several other sources.
Cross posted
ClockWriter , somebody help me - Java Help - CODECALL
dbWhy do they call it rush hour when nothing moves? - Robin Williams
-
Re: Help me with digital clock
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
-
24 hour clock to 12 hour clock project.
By bs3ac in forum New To JavaReplies: 4Last Post: 01-08-2013, 10:10 AM -
digital sign libraries
By Shuru in forum Advanced JavaReplies: 4Last Post: 11-07-2008, 08:01 AM -
Help please in digital clock
By jaidod in forum Java AppletsReplies: 1Last Post: 04-17-2008, 04:05 PM -
need help print random digital
By lowpro in forum New To JavaReplies: 1Last Post: 12-31-2007, 06:47 AM -
need help print char and digital
By lowpro in forum New To JavaReplies: 4Last Post: 12-04-2007, 07:20 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks