Timer in Applet - Source code available

Hello,
I have this timer class which works. How do I include it in an Applet so that my applet
displays time?
Thanks
Mathew
import java.util.*;
public class TimeTest implements Runnable
     Calendar time;
     int hour, minute, second;
     Thread thread = null;
     public TimeTest()
          time = Calendar.getInstance();
          hour = time.get(Calendar.HOUR_OF_DAY);
          minute = time.get(Calendar.MINUTE);
          second = time.get(Calendar.SECOND);
          if(thread == null)
               thread = new Thread(this);
               thread.start();
     public void run()
          try
               Thread t = Thread.currentThread();
               while(thread == t)
                    thread.sleep(1000);
                         second++;
                    if(second > 59)
                         minute++;
                    if(minute>59)
                         hour++;
                    formatTime();
               while(thread != t)
                    thread.suspend();
          catch(Exception e)
               e.printStackTrace();
     public void formatTime()
          second = (second > 59? 0 : second);
          minute = (minute > 59? 0 : minute);
          hour = (hour > 23? 0 : hour);
          System.out.println(hour+":"+minute+":"+second);
     public static void main(String[] args)
          new TimeTest();
     public void stop()
          thread.stop();
}

How about this:
import java.util.*;
import java.text.*;
import java.awt.event.*;
public class Timer 
     javax.swing.Timer timer;
     SimpleDateFormat  timef = new SimpleDateFormat("HH:mm:ss");
public Timer()
     timer = new javax.swing.Timer(1000, new ActionListener()
          public void actionPerformed(ActionEvent e)
               String s = timef.format(new Date(System.currentTimeMillis()));
               System.out.println(s);
     timer.start();
public static void main (String[] args) 
     new Timer();
     while (true){}
}

Similar Messages

  • RealSim Source Code Available to End Users

    Since NI is not going to support the RealSim Product Line or support AC-104's, Will NI make available the source code to End Users that wish to continue using AC-104's and RealSim?
    If not, when will there be an announcment of the third party that will be offering support on these features?

    NI does not intend to make available RealSim source code to end users and is directing customers who wish to continue to use RealSim software/hardware to 3rd parties.
    NI plans to make it easy for customers to target NI hardware, including real-time PXI, with MATRIXx in the future. For information on PXI, please refer to the PXI section www.ni.com/pxi.
    The list of NI Alliance Members (3rd parties) that can provide RealSim support and the parts list for RealSim hardware are now available our online KnowledgeBase. You can access the KnowledgeBase at www.ni.com/support.
    Ash Razdan
    National Instruments
    [email protected]

  • JMS Adapter modules source code available?

    Hi Experts,
    we have to build some modules for the JMS adapter. Is the source code for the existing modules/JavaBeans available somewhere?
    e.g. for the
    AF_Modules/RequestOnewayBean
    AF_Modules/NotifyResponseBean
    Thanks in advance
    Peter

    Hi,
    >>>Is the source code for the existing modules/JavaBeans available somewhere?
    1. no - not in standard 
    2. yes - if you decompile the archive
    Regards,
    Michal Krawczyk

  • Source code available?

    hi, i am just wondering if and when you might release the
    source code so we can have a look? thanks, kevin

    << deleted by myself... I spoke before checking.... those are .class files in coherence-mock.jar >>

  • Signle columnar transposition chiper source codes available?

    I've tried searching google all i can find is codes in C++ i was wondering if there was a java version of any columnar transposition algorithm available.

  • Where can I download the source code of MaxDB (even an older version)?

    Just want to learn some modules of MaxDB. But now I failed to find where to download it.
    Is there any old archive for the older version of MaxDB source code for download?
    Thanks in advance.

    At times when the sources were available I tried to build it on a "new" platform (Solaris x86 32bit) and I can tell you: it's NOTHING that is obvious. Building OpenOffice or Mozilla may appear like an easy task. It took me months to get there and to be able to just build the 'build tools'.
    On top, many of the sources are (historically) written in a Pascal dialect and are transferred to C with an own precompiler so there are three languages used (C, C++ and Pascal)  - so it's a pretty hard (next to impossible) job to learn some algorithms from those sources.
    See also here:
    http://cjcollier.livejournal.com/177628.html
    http://home.snafu.de/~dittmar/sapdbdev/
    and just to get an idea of the modules and their structure:
    http://home.snafu.de/~dittmar/sapdbdev/sapdbModules.txt
    Markus

  • Oracle XML source code

    Does Oracle plan to make the XML parser source code available to
    developers any time in the (near!!) future?
    Donald Wheeler
    null

    That was our intention, but as yet we have not cleared all of
    the legal hurdles and have no anticipated date to announce.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Donald Wheeler (guest) wrote:
    : Does Oracle plan to make the XML parser source code available
    to
    : developers any time in the (near!!) future?
    : Donald Wheeler
    null

  • A* source code

    Just wondering if there are A* source codes available to download. If there are, where can i possibly download it? Just to save some time and effort...maybe i can use it in the mobile game im developing :)
    thanks a lot.

    I once read a really good introductory article on A* on www.gamasutra.com, although as I recall the code was light (meaning, there wasn't a complete finished solution presented). But it introduced the subject of pathfinding and the algorithm well.

  • Am I wasting my time with from source compiles?

    Greetings all,
    I have a question, and it may be silly. I'm a gamer but not a hardcore "zOMG I needZ moRe powAh tHan I actUAlly n33d!" type.
    I've used Gentoo from 2002 - 2006.
    I started using Arch Linux in fall of 2006 and have used it since.
    Couple days ago I "upgraded" from my AMD 64 x2 - 2Ghz system, to a Intel Core 2 Duo E8400 3Ghz system with 4 GB Ram and Geforce 560 Ti. I installed Arch Linux and then I installed Gentoo just for nostalgic and curiosities sake, I had a working Gentoo install within a few hours. I'm not noticing that much of a difference in performance between the two, X seems to load a bit faster on Gentoo but other apps in general load the same, have same performance quality and games have about the same exact framerates. Reguardless if I use "default" USE flags or "all dependencies" USE flags (I tend to be an all dependencies type of guy -- but I did both types for my testings) im not seeing that much, if any at all, performance differences.
    I should also note that: Phoronix Test Suite actually provided better performance numbers in Arch Linux than in Gentoo Linux.
    Now my "silly" question and I want true answers and not just speculative answers.
    Am I wasting my time with Gentoo and from source compiles in general? If I generally tend to do all dep compiles, and im not seeing any performance difference reguardless if I do or don't do the all deps USE flags approach, simular gaming framerates, etc... am I really wasting my time with all the compiles and compile time? Thanks in advance.
    Last edited by Chaniyth (2011-11-21 17:08:26)

    Chaniyth wrote:.....I installed Arch Linux and then I installed Gentoo just for nostalgic and curiosities sake, I had a working Gentoo install within a few hours. I'm not noticing that much of a difference in performance between the two.....I should also note that: Phoronix Test Suite actually provided better performance numbers in Arch Linux than in Gentoo Linux. ..... Am I wasting my time with .. source compiles..?
    IME yes, if your goal is overall performance you ARE wasting your time. I have the same results in benchmarking stock Archlinux vs. the same system recompiled with CFLAGS="-march=native etc." on Sandy Bridge. The recompiled system ran slightly slower on some tests. Quite a bit faster on bzip2 compression. Better x264 performance. Much lower latencies, measured using the interbench package from AUR. But the lower latency depends primarily on the kernel.  I use linux-lqx with arch=native; it is better than linux-ck or linux-pf in my tests.
    I compile everything on my Archlinux system, using xmonad/lxpanel/rox as desktop or, when I'm in an alternate mood, KDE/rox. I don't compile from source for speed (except for math packages like sage-mathematics which can sometimes take advantage of the extra registers and SIMD instructions). I compile from source so that I have a complete system on hand. I once lived off-grid (in a cabin in the Ozark National Forest) and got in the habit of keeping my system ready for self-reliance. I enjoy having source code available for perusal and I modify a few of my packages. I use my own build script that uses meld to help me quickly bring forward my modifications into updated PKGBUILDs from the Arch repository (hey, there's no USE flags but I find that just modifying the PKGBUILD is actually cleaner, less baroque than the circular mess that can happen in Gentoo.)
    One word of caution on your Phoronix benchmarks. Phoronix Test Suite was invented for comparing hardware. It uses its own binaries for many of the tests. When looking for the effect of software changes on the same hardware you should use the changed software (obviously). To do this with PTS you need to go into the ~/.phoronix-test-suite/installed-tests/pts/<test>/ folder and move aside the folder containing the phoronix version of the binary being tested and link to your /usr directory. For example, in the sqlite test folder I move aside "sqlite_" and "ln -s /usr sqlite_"  You can figure how to get each test to run local software by looking at the script in the test folder. If you don't do this, IMO you're getting misleading results from the PTS.

  • Pro Oracle Application Express source code?

    Greetings,
    I bought this book almost a year ago and have yet to see the source code posted on the Apress website. Does anyone know if the source code actually exists or is it vaporware?
    Regards,
    Bill Chadbourne

    Bill,
    somebody's lying and it's not Apress.That's a pretty aggressive accusation, you seem to be taking this almost personally for some reason?
    As the author of the book, I can assure you that I have nothing to gain by not making the source code available (can you think of a single reason?).
    As I mentioned previously, we (myself and APress) are sorting this out as we speak. Please bear with us while we address the issue.
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • Double Click Navigation with ABAP Source Codes of Reports On ABAP Workbench

    Hi,
    i have a problem about double click on abap source code on abap workbench. double clicking doesn't work after first double clicked on abap codes. that is going to row of first double clicking.
    did anyone have the same problem? can somebody help me please?
    thanks.

    Nurullah RÜSTEM wrote:
    > isn't there any radical solution to solve this problem?
    > these are very kill-time
    You feel
    Source Code Editor --> Utilities --> Update Navigation Index
    is not radical & kill-time.
    Can you please define "radical" & "kill-time" ?
    BR,
    Suhas

  • Documentation for source code

    Hi,
    I have just downloaded the source code for the Java 2 SDK v 1.3
    Is the documentation for the source code available ?
    Thanks

    Check this url:
    http://java.sun.com/docs/

  • Can I deploy Mathscript subfunctions without revealing .m source code?

    Good morning.
    I am developing MATLAB algorithms containing functions and subfunctions. To integrate them in LabVIEW, I plan to use Mathscript nodes. And if I do so, I have to leave the subfunctions .m files in a repository on the PC (right?).
    My problem is that I do not want to reveal these easily readable files when deploying my LabVIEW code. So I am looking for a way to deploy this code without making my source code available and open to all.
    Thanks for any help!

    Thanks smercurio.
    smercurio_fc wrote:
    I think Ravens Fan was referring to actually putting the MathScript code inside a MathScript node, not leaving it as its own file. That way the code is saved with the VI.
    Please allow me to illustrate my question through an example.
    Let's say my code is script S1. S1 contains functions f1, f2 and f3, f1 contains subfunctions sf1 and sf2, and so on. I end with a code structure looking like this one (all .m files):
    S1
    - f1
    ---sf1
    ---sf2
    -f2
    ---sf3
    -f3
    ---sf4
    ---sf5
    If S1 is copied in a Mathscript node, how can it work without leaving f1.m, sf1.m and others available on the user's pc after deployment?
    Now, as I understand from my readings and my experimentations, when I put the function and subfunction files in the "LabVIEW Data" file, the functions name in the script S1 copied in a Mathscript node will appear in purple (by default). The node executes fine then. But if I copy the functions in Mathscript nodes in other VIs, the functions name appear in grey, and the node won't work. I don't know how to point to these other Mathscripts... Is there something I miss here?
    smercurio_fc wrote:
    You started out by saying you're developing Matlab algorithms. You should keep in mind that MathScript and Matlab are two different languages. While there are many similarities, there are also a lot of differences, and Matlab code is definitely not 100% compatible in MathScript. Thus, if you write the code in Matlab there is no guarantee it will even work in MathScript.
    Thanks for the warning. I tried my algorithms using the method described above, and they work well.

  • Attatching Source Code To Eclipse IDE

    Please please please can someone help me do this? Its driving me nuts
    I am running JDK 5 and have downloaded Java 5 source cide - I have attatched the code to Eclipse and it still does not show it.
    I have tried this on more then one machine with no luck
    Does anyone know what might cause this and how it can be overcome?
    How do you get the JDK source code available within Eclipse?

    Steve_Johnson wrote:
    I am running JDK 5 and have downloaded Java 5 source cideBut is your Eclipse actually using the JDK? Or just the JRE? Eclipse doesn't need a JDK to run, or to compile code, it'll work just fine with a JRE. Have a look at Windows->Preferences->Java->Installed JREs in your Eclipse, and see what it's actually using. If it's not a JDK, chances are it won't pick up the sources

  • Access to WSDP source code

    Hello,
    I have just installed "Java WSDP" on Linux Red Hat 6.0 and run first example from tutorial.
    Since I have an error I would like to debug it, but it seems there is no source code available.
    I was searching for *.java files in all *.jar files and I could not find source for most classes.
    May be my installation was incorrect? When I ran installation script I got following
    directories:
    -rw-r--r-- 1 root root 10664 Feb 4 13:21 LICENSE
    drwxr-xr-x 2 root root 1024 Feb 4 13:21 bin
    drwxr-xr-x 4 root root 1024 Feb 4 13:21 common
    drwxr-xr-x 2 root root 1024 Feb 4 13:21 conf
    drwxr-xr-x 11 root root 1024 Feb 4 13:21 docs
    drwxr-xr-x 2 root root 1024 Feb 4 13:21 lib
    drwxr-xr-x 2 root root 1024 Feb 4 13:21 logs
    drwxr-xr-x 5 root root 1024 Feb 4 13:21 samples
    drwxr-xr-x 5 root root 1024 Feb 4 13:21 server
    drwxr-xr-x 4 root root 1024 Feb 4 13:21 services
    drwxr-xr-x 4 root root 1024 Feb 4 13:21 shared
    drwxr-xr-x 2 root root 1024 Feb 4 13:21 temp
    drwxr-xr-x 4 root root 1024 Feb 4 13:21 tools
    drwxr-xr-x 4 root root 1024 Feb 4 13:21 webapps
    drwxr-xr-x 2 root root 1024 Feb 4 13:21 work
    Am I missing something? Does anybody can help me?
    Thanks,
    Andrew

    Hello,
    I ran Echo01.class (XML parser) for echo01.txt data and I got SAXException:
    " Content is not allowed in prolog" , but prolog:
    <?xml version='1.0' encoding='UTF-8'?>
    seems to be pretty valid.
    Here is what I did :
    [root@localhost xml_work]# ls -l
    total 12
    -rw-r--r-- 1 root root 2838 Feb 4 15:24 Echo01.class
    -rwxr-xr-x 1 root root 5137 Feb 4 11:54 Echo01.java
    -rwxr-xr-x 1 root root 471 Feb 4 16:38 echo01~1.txt
    drwxr-xr-x 3 root root 1024 Feb 4 15:22 javax
    drwxr-xr-x 5 root root 1024 Feb 4 15:04 org
    [root@localhost xml_work]# java Echo01 echo01~1.txt
    <?xml version='1.0' encoding='UTF-8'?>org.xml.sax.SAXException: Content is not allowed in prolog.
    at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:979)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:374)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:316)
    at Echo01.main(Echo01.java:60)
    [root@localhost xml_work]#
    [root@localhost xml_work]# more echo01~1.txt
    Running Echo01 ../samples/slideSample01.xml
    <?xml version='1.0' encoding='UTF-8'?>
    <slideshow title="Sample Slide Show" date="Date of publication" author="Yours Truly">
    <slide type="all">
    <title>Wake up to WonderWidgets!</title>
    </slide>
    <slide type="all">
    <title>Overview</title>
    <item>Why <em>WonderWidgets</em> are great</item>
    <item></item>
    <item>Who <em>buys</em> WonderWidgets</item>
    </slide>
    </slideshow>
    [root@localhost xml_work]#

Maybe you are looking for

  • How to approach this requirment

    Business  overview: For every organisation account management will be the core functionality. The account management should include the following: customer - company - vendor. 1. customer info 2. vendor info 3.organisation info 4.material info 5.purc

  • Re:checking masterdata char in data dictionary

    Morning gurus if we want to check  the contents of a particular table we  will enter the table name in se16 to view the contents and if the data target  is a masterdata char then we cannot enter the name of that particular field directly we should us

  • Errors Galore

    I've had so many problems with the OWC Mercury Elite Pro drive I got specifically for my Mac Book Pro, which is specifically for working with Pro Tools and Final Cut. I have 6 other cheap external drives which have given me no problems. But I'm using

  • What' the problem with my jvm?

    Someone could tell me what can't i run my jar file to send an email?i can run it on netbeans perfectly . my main classe is this: package send_email; import java.util.Scanner; import javax.swing.JOptionPane; public class Teste {     public Teste() {  

  • Roll Out Brazil

    Hello FI Gurus: My customer is a Global Organization who is expecting to initiate a Roll Out in Brazil. The Corporate is using now a Global Chart of Account as operational Chart of account. Now the people in Brazil is requesting to have its own Chart