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)

PDF
The AI Revolution in Customer Service - 2025
PDF
Auditboard EB SOX Playbook 2023 edition.
PDF
LMS bot: enhanced learning management systems for improved student learning e...
PDF
Co-training pseudo-labeling for text classification with support vector machi...
PPTX
Module 1 Introduction to Web Programming .pptx
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
Early detection and classification of bone marrow changes in lumbar vertebrae...
PPTX
Presentation - Principles of Instructional Design.pptx
PDF
Introduction to MCP and A2A Protocols: Enabling Agent Communication
PDF
Electrocardiogram sequences data analytics and classification using unsupervi...
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PDF
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
PDF
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
PDF
CEH Module 2 Footprinting CEH V13, concepts
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
PDF
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
PDF
EIS-Webinar-Regulated-Industries-2025-08.pdf
PDF
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
The AI Revolution in Customer Service - 2025
Auditboard EB SOX Playbook 2023 edition.
LMS bot: enhanced learning management systems for improved student learning e...
Co-training pseudo-labeling for text classification with support vector machi...
Module 1 Introduction to Web Programming .pptx
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
Early detection and classification of bone marrow changes in lumbar vertebrae...
Presentation - Principles of Instructional Design.pptx
Introduction to MCP and A2A Protocols: Enabling Agent Communication
Electrocardiogram sequences data analytics and classification using unsupervi...
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
CEH Module 2 Footprinting CEH V13, concepts
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
EIS-Webinar-Regulated-Industries-2025-08.pdf
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
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