Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tick;
- import java.math.*;
- import javax.swing.*;
- import java.awt.*;
- import java.util.*;
- public class ClockCreate {
- private String title;
- private int size;
- private JFrame newJFrame;
- private Graphics face;
- private int width;
- private int xcenter = 225;
- private int ycenter = 225;
- private int height = width;
- private int mhandlength;
- private int hhandlength;
- private int hour,minute;
- public ClockCreate(String title,int size) {
- this.title = title;
- this.size = size;
- drawPane();
- }
- //public int getUserInput(){}
- //Scanner function to get user input
- //public void evaluateUserInput(){}
- //User chooses simple(unlabeled) or complex (labeled)
- //clock; figure out how to get user input from above and do
- //something with either option
- public void drawPane() {
- JFrame win= new JFrame(title);
- win.setSize(450, 450); // (size, size)
- win.setLocation(100, 100);
- win.setVisible(true);
- Container contentPane=win.getContentPane();
- //Create contentPane on window
- contentPane.setBackground(Color.LIGHT_GRAY);
- Graphics g =contentPane.getGraphics();
- g.setColor(Color.GREEN);
- drawFace();
- }
- public void drawFace() {
- // Draw the inside of the clock
- Graphics face = contentPane.getGraphics();
- face.drawOval(25, 25, 400, 400);
- face.setColor(new Color(100,200,100));
- }
- public void drawLabel() {
- draw.String("12",x,y)
- draw.String("1",x,y)
- draw.String("2",x,y)
- draw.String("3",x,y)
- draw.String("4",x,y)
- draw.String("5",x,y)
- draw.String("6",x,y)
- draw.String("7",x,y)
- draw.String("8",x,y)
- draw.String("9",x,y)
- draw.String("10",x,y)
- draw.String("11",x,y)
- }
- }
- public void drawHour(int hour, int minute) {
- xhour = (int) (Math.cos((hour * 30 + minute / 2) * 3.14f / 180 - 3.14f / 2) * 80 + xcenter);
- yhour = (int) (Math.sin((hour * 30 + minute / 2) * 3.14f / 180 - 3.14f / 2) * 80 + ycenter);
- }
- public void drawMinute(int hour, int minute) {
- xminute = (int) (Math.cos(minute * 3.14f / 30 - 3.14f / 2) * 100 + xcenter);
- yminute = (int) (Math.sin(minute * 3.14f / 30 - 3.14f / 2) * 100 + ycenter);
- }
- public void cycleTime(int hour, int minute) {
- drawHour(12,0);
- drawMinute(12,0);
- drawMinute(12,30);
- drawHour(1,0);
- drawMinute(1,0);
- drawMinute(1,30)
- etc
- }
- //Create New Clock
- //Prompt User to choose Labaled or Unlabaled Clock
- //Draw pane/canvase
- //draw clock face
- //Draw label if user choose label option.
- //Draw hour hand at Hour--minute hand at 12 and then 30--> next hour etc
- //12-1230/1-130/2-230/3-330/4-etcetc
- //Close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement