Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #4719

Re: pls hlep, can't get output

From Knute Johnson <nospam@knutejohnson.com>
Newsgroups comp.lang.java.gui
Subject Re: pls hlep, can't get output
Date 2011-10-30 20:28 -0700
Organization A noiseless patient Spider
Message-ID <j8l4k2$5mp$1@dont-email.me> (permalink)
References <33f44292-1f4f-4084-acee-259e633dbb59@x16g2000prd.googlegroups.com>

Show all headers | View raw


On 10/17/2011 9:07 PM, kk wrote:
> This is program.But problem is that there is no output.I faded to
> catch the problem.
>
> import java.awt.*;
> import javax.swing.*;
> import java.util.Calendar;
> class ClockDemo extends  Canvas{
>
>                 int xmou=200; //set the center of circle
>                 int ymou=200; //set the center of circle
>
>                 double theta=-0.1047; //theta for second's hand
>                 int x=xmou;  //x position of Second's hand
>                 int y=ymou;  //y position of second's hand
>                 int p,b;
>                 int h;
>                 boolean flag=true;
>                 /*ClockDemo(){
>                         //super();
>                         setSize(500,500);
>                         setBackground(Color.PINK);
>                         setVisible(true);
>                 }*/
>                 public void paint(Graphics g){
>                         DrawLine(g,xmou,ymou,x,y);
>
>
>                 }
>                 public void DrawLine(Graphics g,int startX,int
> startY,int endX,int
> endY){
>                         h=80;
>                         System.out.println("h:"+h);
>                         //g.drawLine(200,200,165,248);
>                         while(true){
>
>
>
>                                 g.drawLine(startX,startY,endX,endY);
>                                 newpoint();
>                                 //
> this.repaint(startX,startY,endX,endY);
>                                 try{
>       Thread.sleep(1000);
>       }catch(Exception e){}
>                         }
>                 }
>                 public void newpoint(){
>
>      Calendar now = Calendar.getInstance(); //creating a Calendar
> variable for getting current time
>
>      //for second hand
>      //h=60;
>      x=xmou;
>      y=ymou;
>      theta=-0.1047;
>      theta=theta*now.get(Calendar.SECOND);
>      System.out.println("theta:"+theta);
>      p=  (int) (Math.sin(theta) * h);
>      b=  (int) (Math.cos(theta) * h);
>      System.out.println("p:"+p+" "+"b:"+b);
>      x=x-p;
>      y=y-b;
>
>      }
>
> For veiwing
>
>
> import javax.swing.*;
> import java.awt.*;
> class ClockDemoViewer {
>         public static void main(String... arg){
>                 ClockDemo comp=new ClockDemo();
>                 JFrame jf=new JFrame("Clock Demo");
>
>                 jf.add(comp);
>                 jf.setSize(500,500);
>                 jf.setVisible(true);
>
> jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
>         }
> }

Here is a really good example of how to do it, if I do say so myself.

http://rabbitbrush.frazmtn.com/clock.html

-- 

Knute Johnson

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

pls hlep, can't get output kk <kcool.99x@gmail.com> - 2011-10-17 21:07 -0700
  Re: pls hlep, can't get output Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-10-18 09:25 -0700
  Re: pls hlep, can't get output Roedy Green <see_website@mindprod.com.invalid> - 2011-10-30 20:17 -0700
  Re: pls hlep, can't get output Knute Johnson <nospam@knutejohnson.com> - 2011-10-30 20:28 -0700
  Re: pls hlep, can't get output Roedy Green <see_website@mindprod.com.invalid> - 2011-10-30 22:21 -0700

csiph-web