SlideShare a Scribd company logo
ClockProj
//This is clock me made for project.
//Instructed: input time and clock hand is too display time properly.
//Clock hand no work properly
//sorry for bad english.

import    javax.swing.*;
import    java.awt.Graphics;
import    java.awt.font.FontRenderContext;
import    java.awt.Color;
import    javax.swing.JFrame;
import    java.awt.font.TextLayout;



public class Clock extends JFrame{
    private int x1=100;
    private int y1=70;
    private int x1a=100;
    private int y1a=10;
    JFrame frame;
    private int x2;
    private int y2;
     String Hour = JOptionPane.showInputDialog("Hr:");
           int ho = Integer.parseInt(Hour);
     String Minutes = JOptionPane.showInputDialog("Mins:");
          int mi = Integer.parseInt(Minutes);
    private float theta=55 - (30*ho) + 30; //minus 30 per hour 55
    private float theta2=55 - (6*mi); //minus 6 per min 55
    private int d,e;
    public clock() {
         setTitle("Clock");
         setSize(600,600);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setVisible(true);
    }
      public void paint(Graphics g) {
       g.fillRect(0,0,500,500);
       g.setColor(Color.BLUE);
         g.drawString("12", 250, 129); //place of clock
         g.drawString("1", 311, 145);
         g.drawString("2", 355, 189);
         g.drawString("3", 371, 250);
         g.drawString("4", 355, 311);
         g.drawString("5", 311, 355);
         g.drawString("6", 250, 371);
         g.drawString("7", 189, 355);
         g.drawString("8", 145, 311);
         g.drawString("9", 129, 250);
         g.drawString("10", 145, 189);
         g.drawString("11", 189, 145);

       g.setColor(Color.WHITE); //hours
            x2=((int)(x1a*Math.cos(theta*Math.PI/180)))-((int)(y1a*
Math.sin(theta*Math.PI/180)));
            y2=((int)(x1a*Math.sin(theta*Math.PI/180)))+((int)(y1a*
Math.cos(theta*Math.PI/180)));
            g.drawLine(250,250,x2+250,250-y2);
        g.setColor(Color.BLUE);           //minutes
           d=((int)(x1*Math.cos(theta2*Math.PI/180)))-((int)(y1*
Math.sin(theta2*Math.PI/180)));
            e=((int)(x1*Math.sin(theta2*Math.PI/180)))+((int)(y1*
                                      Page 1
ClockProj
Math.cos(theta2*Math.PI/180)));
            g.drawLine(250,250,d+250,250-e);

             g.setColor(Color.RED);
        g.drawString("The Time is: "+Hour+":"+Minutes+" ", 0, 0); //place time here
    }
      public static void main(String[] args) {
    new clock();
    }
}




                                       Page 2

More Related Content

DOCX
Project code for Project on Student information management system
PDF
DOCX
Experement no 6
DOCX
Caropro
DOCX
Assignement c++
DOCX
Code for program to draw a circle using mid point circle algorithm in c
PDF
Brief intro to clojure
Project code for Project on Student information management system
Experement no 6
Caropro
Assignement c++
Code for program to draw a circle using mid point circle algorithm in c
Brief intro to clojure

What's hot (18)

DOCX
Include
TXT
C code
PDF
Insertion sort
DOCX
C programs
DOCX
Numerical Method Assignment
DOCX
PDF
VTU Network lab programs
DOCX
Modificacion del programa
PPTX
MongoDB
PDF
Oopsprc1c
PPTX
Better performance through Superscalarity
DOCX
2 d rotation
DOC
Praktikum Komputasi Statistika
DOCX
Document
PPTX
Oops in c++
PDF
Probability of finding a single qubit in a state
PDF
Implementation of c string functions
DOCX
Programa donde suma las filass de las dos columna y ordena el resultado de l...
Include
C code
Insertion sort
C programs
Numerical Method Assignment
VTU Network lab programs
Modificacion del programa
MongoDB
Oopsprc1c
Better performance through Superscalarity
2 d rotation
Praktikum Komputasi Statistika
Document
Oops in c++
Probability of finding a single qubit in a state
Implementation of c string functions
Programa donde suma las filass de las dos columna y ordena el resultado de l...
Ad

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Cloud computing and distributed systems.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Machine learning based COVID-19 study performance prediction
Dropbox Q2 2025 Financial Results & Investor Presentation
MYSQL Presentation for SQL database connectivity
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Network Security Unit 5.pdf for BCA BBA.
MIND Revenue Release Quarter 2 2025 Press Release
Understanding_Digital_Forensics_Presentation.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
20250228 LYD VKU AI Blended-Learning.pptx
sap open course for s4hana steps from ECC to s4
Programs and apps: productivity, graphics, security and other tools
Cloud computing and distributed systems.
NewMind AI Weekly Chronicles - August'25 Week I
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Big Data Technologies - Introduction.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Ad

Clock For My

  • 1. ClockProj //This is clock me made for project. //Instructed: input time and clock hand is too display time properly. //Clock hand no work properly //sorry for bad english. import javax.swing.*; import java.awt.Graphics; import java.awt.font.FontRenderContext; import java.awt.Color; import javax.swing.JFrame; import java.awt.font.TextLayout; public class Clock extends JFrame{ private int x1=100; private int y1=70; private int x1a=100; private int y1a=10; JFrame frame; private int x2; private int y2; String Hour = JOptionPane.showInputDialog("Hr:"); int ho = Integer.parseInt(Hour); String Minutes = JOptionPane.showInputDialog("Mins:"); int mi = Integer.parseInt(Minutes); private float theta=55 - (30*ho) + 30; //minus 30 per hour 55 private float theta2=55 - (6*mi); //minus 6 per min 55 private int d,e; public clock() { setTitle("Clock"); setSize(600,600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public void paint(Graphics g) { g.fillRect(0,0,500,500); g.setColor(Color.BLUE); g.drawString("12", 250, 129); //place of clock g.drawString("1", 311, 145); g.drawString("2", 355, 189); g.drawString("3", 371, 250); g.drawString("4", 355, 311); g.drawString("5", 311, 355); g.drawString("6", 250, 371); g.drawString("7", 189, 355); g.drawString("8", 145, 311); g.drawString("9", 129, 250); g.drawString("10", 145, 189); g.drawString("11", 189, 145); g.setColor(Color.WHITE); //hours x2=((int)(x1a*Math.cos(theta*Math.PI/180)))-((int)(y1a* Math.sin(theta*Math.PI/180))); y2=((int)(x1a*Math.sin(theta*Math.PI/180)))+((int)(y1a* Math.cos(theta*Math.PI/180))); g.drawLine(250,250,x2+250,250-y2); g.setColor(Color.BLUE); //minutes d=((int)(x1*Math.cos(theta2*Math.PI/180)))-((int)(y1* Math.sin(theta2*Math.PI/180))); e=((int)(x1*Math.sin(theta2*Math.PI/180)))+((int)(y1* Page 1
  • 2. ClockProj Math.cos(theta2*Math.PI/180))); g.drawLine(250,250,d+250,250-e); g.setColor(Color.RED); g.drawString("The Time is: "+Hour+":"+Minutes+" ", 0, 0); //place time here } public static void main(String[] args) { new clock(); } } Page 2