« Return to Thread: Clock help

Re: Clock help

by joshis :: Rate this Message:

Reply to Author | View in Thread

Hi!

Do you mean something like this (the simplest/likely-dumbest
implementation possible)? You might play with the appearance, output
format, etc... The key portion of code:

    public NewJFrame() {
        initComponents();
        jLabel1.setText(Calendar.getInstance().getTime().toString());

        _iTimer = new Timer(true);
        _iTimer.scheduleAtFixedRate(new TimerTask() {

            @Override
            public void run() {
               
jLabel1.setText(Calendar.getInstance().getTime().toString());
            }
        }, 1000, 1000);
    }

With regards,

Petr Dvorak

Doctor Sup wrote:
> I am very new to Netbeans and java programming in general so excuse my
> ignorance, but i am trying to implement a simple digital clock via a Jlabel
> but when i attempt to add a TimerBean it says "Components from the default
> package cannot be used outside of the default pakage" what does this mean?
> and more importantly how can i implement this clock ( as a basic decktop
> aplication ).
>
> Thankyou for any help.
>  



clock.zip (20K) Download Attachment

 « Return to Thread: Clock help