//The error message I'm getting is saying "cannot find symbol- method second(double)
but I feel as though I have identified everything already. (I'm clearly wrong). I think there is a problem with the formula as well but that is the code I was given for the formula. Any help would be greatly appreciated.
import java.util.GregorianCalendar;
import javax.swing.JComponent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.*;//import * Class
public class ClockComponent extends JComponent
{
double hour;
double minute;
double second;
public void setCurrentTime()
{
GregorianCalendar calendar = new GregorianCalendar();
hour = calendar.get(calendar.HOUR_OF_DAY);
minute = calendar.get(calendar.MINUTE);
second = calendar.get(calendar.SECOND);
}
public void paintComponent(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
int xCoord = 40;
int yCoord = 25;
Ellipse2D.Double clockFace = new Ellipse2D.Double(xCoord, yCoord, 700, 700);
g2.setColor(Color.black);
g2.draw(clockFace);
g2.fill(clockFace);
g2.setColor(Color.red);
Font font1 = new Font("Old English Text MT",Font.BOLD,30);
g2.setFont(font1);
g2.drawString("John Doe", 305, 680);
g2.setColor(Color.yellow);
Font font2 = new Font("Arial",Font.BOLD,30);
g2.setFont(font2);
g2.drawString("III", xCoord + 670, yCoord + 355);
g2.drawString("VI", xCoord + 340, yCoord + 685);
g2.drawString("IX", xCoord + 10, yCoord + 355);
g2.drawString("XII", xCoord + 340, yCoord + 35);
int xCenter = 380;
int yCenter = 380;
double secondHandLength;
double minuteHandLength;
double hourHandLength;
double xSecond = xCenter + secondHandLength; cos(second (2*Math.PI/60));
double ySecond = yCenter - secondHandLength; sin(second (2*Math.PI/60));
double xMinute = xCenter + minuteHandLength; cos(2*Math.PI/60);
double yMinute = yCenter - minuteHandLength; sin(2*Math.PI/60);
double xHour = xCenter + hourHandLength; cos(2*Math.PI/60);
double yHour = yCenter - hourHandLength; sin(2*Math.PI/60);
g2.setColor(Color.blue);
Line2D.Double secHand = new Line2D.Double(xCenter,yCenter,xSecond,ySecond);
g2.setStroke(new BasicStroke(1));
g2.draw(secHand);
Line2D.Double minHand = new Line2D.Double(xCenter,yCenter,xMinute,yMinute);
g2.setStroke(new BasicStroke(7));
g2.draw(minHand);
Line2D.Double hourHand = new Line2D.Double(xCenter,yCenter,xHour,yHour);
g2.setStroke(new BasicStroke(13));
g2.draw(hourHand);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…