Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.60 KB | None | 0 0
  1. package tick;
  2. import java.math.*;
  3. import javax.swing.*;
  4. import java.awt.*;
  5. import java.util.*;
  6.  
  7.  
  8. public class ClockCreate {
  9.     private String title;
  10.     private int size;
  11.     private JFrame newJFrame;
  12.     private Graphics face;
  13.     private int width;
  14.     private int xcenter = 225;
  15.     private int ycenter = 225;
  16.     private int height = width;
  17.     private int mhandlength;
  18.     private int hhandlength;
  19.     private int hour,minute;
  20.    
  21.     public ClockCreate(String title,int size) {
  22.         this.title = title;
  23.         this.size = size;
  24.         drawPane();
  25.                
  26.        
  27.     }
  28.     //public int getUserInput(){}
  29.     //Scanner function to get user input
  30.    
  31.     //public void evaluateUserInput(){}
  32.     //User chooses simple(unlabeled) or complex (labeled)
  33.     //clock; figure out how to get user input from above and do
  34.     //something with either option
  35.  
  36.     public void drawPane() {
  37.         JFrame win= new JFrame(title);
  38.         win.setSize(450, 450); // (size, size)
  39.         win.setLocation(100, 100);
  40.         win.setVisible(true);
  41.         Container contentPane=win.getContentPane();
  42.         //Create contentPane on window
  43.         contentPane.setBackground(Color.LIGHT_GRAY);
  44.         Graphics g =contentPane.getGraphics();
  45.         g.setColor(Color.GREEN);
  46.         drawFace();
  47.     }
  48.    
  49.     public void drawFace() {
  50.  
  51.         // Draw the inside of the clock
  52.         Graphics face = contentPane.getGraphics();
  53.         face.drawOval(25, 25, 400, 400);
  54.         face.setColor(new Color(100,200,100));
  55.  
  56.     }
  57.     public void drawLabel() {
  58.        
  59.         draw.String("12",x,y)
  60.         draw.String("1",x,y)
  61.         draw.String("2",x,y)
  62.         draw.String("3",x,y)
  63.         draw.String("4",x,y)
  64.         draw.String("5",x,y)
  65.         draw.String("6",x,y)
  66.         draw.String("7",x,y)
  67.         draw.String("8",x,y)
  68.         draw.String("9",x,y)
  69.         draw.String("10",x,y)
  70.         draw.String("11",x,y)
  71.    
  72.          }
  73.        
  74.     }
  75.     public void drawHour(int hour, int minute) {
  76.         xhour = (int) (Math.cos((hour * 30 + minute / 2) * 3.14f / 180 - 3.14f / 2) * 80 + xcenter);
  77.  
  78.         yhour = (int) (Math.sin((hour * 30 + minute / 2) * 3.14f / 180 - 3.14f / 2) * 80 + ycenter);
  79.        
  80.        
  81.     }
  82.     public void drawMinute(int hour, int minute) {
  83.         xminute = (int) (Math.cos(minute * 3.14f / 30 - 3.14f / 2) * 100 + xcenter);
  84.  
  85.         yminute = (int) (Math.sin(minute * 3.14f / 30 - 3.14f / 2) * 100 + ycenter);
  86.  
  87.     }
  88.    
  89.     public void cycleTime(int hour, int minute) {
  90.         drawHour(12,0);
  91.         drawMinute(12,0);
  92.         drawMinute(12,30);
  93.         drawHour(1,0);
  94.         drawMinute(1,0);
  95.         drawMinute(1,30)
  96.         etc
  97. }
  98.  
  99.  
  100.  
  101. //Create New Clock
  102. //Prompt User to choose Labaled or Unlabaled Clock
  103. //Draw pane/canvase
  104. //draw clock face
  105. //Draw label if user choose label option.
  106. //Draw hour hand at Hour--minute hand at 12 and then 30--> next hour etc
  107. //12-1230/1-130/2-230/3-330/4-etcetc
  108. //Close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement