Digital clock example(with thread).

Can you write me a example of a simple digital clock?
And btw is there a tutorial for threading on the site?

Can you write me a example of a simple digital clock?ingredients:
JLabel
Date
SimpleDateFormat
Swing Timer
have a go at making your own, post any specific problem you have

Similar Messages

  • Digital clock reset problem with 74193N

    Hi, i'm designing a digital clock circuit.
    However, i faced problems during reset part.
    when i tried to reset on 3(U11) with 1 NAND gate and 2 NOR gates,
    i think i don't make mistake to reset with 0011(U3),how come the 3 will also appear on the seven-segment display?
    Well,i also wonder how can i reset  the other seven-segment display(U9) to show the following sequences:
    0,1,2,3,4,5,6,7,8,9,0,1,2,3,0,1,2,3,4,5,6,7,8,9,0,1,2,3,0.. 
    Lastly, is that possible to configure the transmition speed in multisim 11.0?
    Thanks.. 
    Attachments:
    NEW140712.ms11 ‏363 KB

    Hi,
    There were a few problems with the circuit which is why the clock was not reseting at 3. I have modified the file. Please take a look and see. You will need to add a buffer between the second input and the AND gate because otherwise, the gate will trigger before the output has actually reached the desired state.
    I had to edit the delay time in the buffer to make it work of this circuit. To edit the delay time, double-click the Buffer and under the Value tab, click on Edit Model. You can change the rise time and fall time from this window.
    Hope this helps.
    Regards,
    Tayyab R,
    National Instruments.
    Attachments:
    NEW140712 mod.ms11 ‏545 KB

  • [SOLVED] Thunderbird integration with KDE Digital Clock Widget

    Is there a way to integrate Thunderbird's Lightning calendar extension with the KDE Digital Clock widget (default clock) so that clicking on it shows you your calendar events? Something similar like using the Evolution Data Server Mirror to sync with the GNOME Panel clock.
    I have tried fiddling with various widgets, exporting iCalendars and importing with Personal Information settings, but nothing has worked so far.
    Last edited by cornelus (2012-06-07 08:45:16)

    Hello
    I use these steps in Thunderbird 31:
    "New Calendar" >> "On the Network" >> "iCalendar (ICS)"
    and use the "file://" protocol for the "Location" and give it the path of iCalendar file I use in the Akonadi/KOrganizer, i.e: "file:///home/MYNAME/calendar.ics"
    also check the calndar "Properties" and uncheck the "Read Only", if it is necessary.

  • How to acquire serial data on a digital input line with good performance?

    Hello,
    we have a performance problem with our realtime controller. Our objective is, to read a 24-bit long digital waveform from a digital input line. To do this, we supply a clock signal (236 KHz)  to the PFI1 Line of our DAQ Board. On each rising edge of the clock, a new bit is set on the digital input DI0.
    Our hardware which transmits the data, is triggered through a digital output from our realtime controller. On each edge on this output, the hardware starts a serial transmission of 24-Bits.
    Everything works fine except the bad performance of our realtime controller. We want to acquire the 24-Bits in a 1ms timed loop. To measure performance we wrote a test program. In that, we only triggered the hardware and transfered the data to the realtime controller. The task which is doing this job, has a approx. CPU-Load of 30%, which is, in my humble opinion, very high. The task is not waiting for data or anything else! We have earlier implemented a control which is also using a 1ms timed loop. This control is sampling 2 analog input signals, 2 counters. Futhermore it's sending telegrams with CAN and doing many calculations. The strange thing is, this much huger program has a CPU-Load of 25%. Does anybody know where the problem is?
    For the better understandig I attached our test-program to this text.
    We're using:
    PXI-8175 realtime controler
    PXI-6221 Multifunction DAQ
    Thanks!
    Regards, 
       Crest!
    Attachments:
    dig_test.zip ‏51 KB

    Hello,
    First of all 30% CPU-Load is normal because the DAQmx-driver needs a lot of resources.
    In your programm you should place a wait (for example with 1ms) into the while-loop which causes
    lower CPU-Load.
    If this is not enough you should build your vi like in the following example.
    Regards,
    Christian
    Attachments:
    Read Dig Port.vi ‏51 KB

  • Digital clock which randomly selects different colors from Applet

    Hi,
    I relatively new to java, what I'm trying to do is list about five colours in my Applet and pass the colours into my java code, and maybe the font.....
    I want to be able to Display a digital clock which randomly selects different colours which were passed from my Applet
    Thanks for any help
    Zip
    Clock Code:
    import java.awt.*;
    import java.applet.*;
    import java.util.*;
    import java.text.*;
    public class dclock extends Applet implements Runnable{
    Thread animThread = null;
    int delay = 1000;
    public void init(){}
    public void paint (Graphics g){
    // get the time
    Calendar cal = Calendar.getInstance();
    Date date = cal.getTime();
    // format it and display it
    DateFormat dateFormatter =DateFormat.getTimeInstance();
    g.drawString(dateFormatter.format(date), 5, 10);
    public void start(){
    if(animThread == null){
    animThread = new Thread(this,"Animation");
    animThread.start();
    public void stop(){animThread = null;}
    public void run(){
    while(animThread !=null){
    try{ Thread.sleep(delay);}
    catch(InterruptedException e){};
    repaint();
    //sec++;
    }

    Why doesn't the clock just decide what colour it is going to be? If you need to pass the colour choices in, just let the clock accept a collection of colours in its constructor or something. I don't understand what bit of this you are having problems with as you haven't really explained. Please also use code tags.

  • Digital clock timer to turn on/off lights at certain times

    Hello i am an undergraduate student curently doing a project.
    I am making a automated plant growing system.
    i need help in creating a VI that can use a digital clock to input a time for grow lights and a water pump to turn on and off.
    Il will be using GPIB power supplies to power both.

    Hi,
    Graham is currently out of the office, so I am taking over dealing with this support request.
    I have attached a VI which shows an example of how to read the current time from the Time Stamp, and then specify a Start and End Time for the lights in your system to turn on. The example currently just activates an LED on the Front Panel, but you should be able to easily change this to an operation that sends the different string commands you require to your power supply for the lights and the water pump to turn them on and off respectively.
    Regards,
    Dan
    Attachments:
    Lights Controller.vi ‏16 KB

  • Simple digital clock script

    Hi All,
    Since I am a new bee, I am seeking a simple digital clock MIDlet. Last two days I have been searching internet but I haven't found. If you do not consider me as RTFM or too lazy, could you please either post a script or simple give a shortcut?
    Many thanks in advance
    seyyah

    deepspace,
    this is my code but it is not updating. I know tha I am being too much. Help is really appriciated.
    * DrawImage.java
    * Draw mutable image on a canvas
    import java.util.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class emuezzin extends MIDlet
    private Display display; // The display
    private ImageCanvas canvas; // Canvas
    public emuezzin()
    display = Display.getDisplay(this);
    canvas = new ImageCanvas(this);
    protected void startApp()
    display.setCurrent( canvas );
    protected void pauseApp()
    protected void destroyApp( boolean unconditional )
    public void exitMIDlet()
    destroyApp(true);
    notifyDestroyed();
    * Class ImageCanvas
    * Draw mutable image
    class ImageCanvas extends Canvas implements CommandListener
    private Command cmExit; // Exit midlet
    private emuezzin midlet;
    private Image im = null;
    private String message = "developerWorks 1";
    public ImageCanvas(emuezzin midlet)
    this.midlet = midlet;
    // Create exit command and listen for events
    cmExit = new Command("Exit", Command.EXIT, 1);
    addCommand(cmExit);
    setCommandListener(this);
    * Draw mutable image
    protected void paint(Graphics g)
    // Clear the display
    Calendar now = Calendar.getInstance();
    int hours = now.get(Calendar.HOUR_OF_DAY);
    int minutes = now.get(Calendar.MINUTE);
    int seconds = now.get(Calendar.SECOND);
    String message = hours+":"+minutes+":"+ seconds;
    System.out.println("Current Time = "+message);
    // Create mutable image
    im = Image.createImage(100, 20);
    // Get graphics object to draw onto the image
    Graphics graphics = im.getGraphics();
    // Specify a font face, style and size
    Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
         graphics.setFont(font);
    // Draw a filled (blue) rectangle, with rounded corners
    graphics.setColor(0, 0, 255);
         graphics.fillRoundRect(0,0, im.getWidth()-1, im.getHeight()-1, 20, 20);
         // Center text horizontally in the image. Draw text in white
    graphics.setColor(255, 255, 255);
    graphics.drawString(message,
              (im.getWidth() / 2) - (font.stringWidth(message) / 2),
              (im.getHeight() / 2) - (font.getHeight() / 2),
              Graphics.TOP | Graphics.LEFT);
    g.setColor(255, 255, 255);
    g.fillRect(0, 0, getWidth(), getHeight());
    // Center the image on the display
    if (im != null)
    g.drawImage(im, getWidth() / 2, getHeight() / 2,
    Graphics.VCENTER | Graphics.HCENTER);
    public void run(){
    while(true){
    repaint();
    try{
    System.out.println("Current Time =");
    Thread.sleep(1000);
    } catch (Exception e){}
    public void commandAction(Command c, Displayable d)
    if (c == cmExit)
    midlet.exitMIDlet();
    }

  • Making a digital clock

    Hello, I am learning java and i can make simple programs. i have only taken 2 years of java programmin in school.
    i wanted to try something harder, i don't know if i am ready for it or not.
    I want to make a digital clock in java, and maybe modify it by adding buttons to increase hours and mins.
    I have kinda starte it. but i need a lot of help.

    by the nature of your questions, it appears that you don't know much about swing, timers, and java date time functions. We can't just tell you what you need for your clock, otherwise we'd be building it for you. What you need to do is study these areas and learn for yourself. I suggest that you start with the Sun Java Swing tutorials. Start out here:
    http://java.sun.com/docs/books/tutorial/ui/index.html
    and
    http://java.sun.com/docs/books/tutorial/uiswing/index.html

  • Multi-channel digital audio HDMI with Onkyo pre-pro

    Trying to get the HDMI to play nice with my home theatre pre-processor, an Onkyo Pro PR-SC886. so far:
    1. I am setting the Sound Pref Output to the Onkyo, which it sees.
    2. Setting the Midi Pref to HDMI/Onkyo which it sees.
    3. I would like to get a digital stream to the Onkyo which it can convert to Dolby Pro Logic II which is my preferred choice for stereo music. So far, I can only get Stereo which the Onkyo will not convert.
    4. In the Midi Pref, I have selected 192Hz/24-8channel output and the speakers are set to 5.1. Everything seems to work there.
    5. I was hoping to use the "Encoded Digital Audio" choice, but get no sound when I use it.
    Is this an Onkyo problem and are others able to use the Encoded Digital Audio setting with another brand of pre-pro/receiver? Or is this choice used for something else?
    Thanks for any insight.
    Peter

    It seems that Onkyo's HDMI components don't like the HDMI output from computers. There have been several threads in this forum and others where Onkyo owners report issues.
    But do try the instructions listed here to see if it makes a difference...
    http://www.cod3r.com/2008/02/the-correct-way-to-enable-ac3-passthrough-with-quic ktime/
    An alternative media player option is VLC. And you need to turn on the SPDIF option in the audio preferences of this app.

  • Just need 1/8 inch to RCA for digital coax out with audigy se right?

    DJust need /8 inch to RCA for digital coax out with audigy se right? Hi there,
    I need a low profile soundcard that can deli'ver digital 5. through either coax or optical, looks like the audigy se will do just that. I have a yamaha receiver with DTS, DD, etc with a coax input that I want to use. I want to confirm that all I really need is a cable that has an /8 inch plug for the blue digital out on the soundcard with an RCA end for my receiver.... sounds simple enough to me but I want to make sure. I know I can get the digital I/O module but don't see a point if I just need the cable I mentioned.
    Thanks.
    Message Edited by recklessftw on 0-22-2009 09:3 [email protected]

    Let's take Battlefield 242 for example. The game will not allow me to specify hardware sound.
    That would be because that card DOES NOT have any hardware on it, it is a totally software dri'ven card.
    And yes your old Li've card is much better than the Audigy SE. The Audigy SE is nothing more than a re-named SB Li've 24 bit, which is also a software based card (same applies to the X-Fi Xtreme Audio, a POS card that should have never been given the X-Fi name).

  • Design issue with threads ...

    Hello,
    I need your thoughts in how to proper use java threads in solving this issue:
    * I have an application that query a database for a list of users, and for each row retrieved from the database as a result the application should process that user and send him an email.
    Now the procdural approach for looping each user and send him an email at a time is not convinient as the number of users is big (20,000 users or more) so I thought of why not to use threads to send say every 300 user at a time (i.e, creating 300 threads), but the problem is that I cannot really figure how to manage those threads, to make sure that there are 300 threads are running all the time, and what if a thread was taking more time that the others ... etc.
    So, is this approach is the right one, and can you guide more more for how to control the threads this way, if not what do you suggest?
    Your guidance is highly appreciated,
    tamer

    I'm not sure that threads will help your cause. But they could. Let me explain:
    Threads have several purposes. Two instantly spring to mind:
    1. to make things faster.
    2. to (make it seem like you) do two (or more things) at once.
    First #2. This is often a usability issue. For example, a web server has to server multiple clients at the "same time". This is often done with threads - it gives the illusion that many concurrent users are supported. In reality the CPU/JVM is swapping beween the different requests. More CPUs allow for "realer" concurrency. Speed is only a by-product here.
    Now #1: Make things faster. Threading works well for speed when the tasks being done differ.
    For example, consider human multithreading: ask me to whistle for 5 seconds, and 5 seconds later I'll be done. Then ask me to scratch my head with both hands for 5 seconds, and 5 seconds later I'll be done. Total: 10 seconds. Ask me to do both at the same time. Result: 5 seconds later I'll have scratched my head and whistled for 5 seconds. 50% time saving.
    However, ask me to touch type for 5 seconds, and scratch my head for 5 seconds, it'll take 10 seconds or more. If you ask me to do one, then the other, I can spend 5 seconds at one then the other - total 10 seconds. Ask me to do both concurrently, and I'll take more than 10 seconds, as I'll be moving my hands back and forth from the keyboard to my head, and vice-versa.
    I have a feeling that running multiple threads in your case would be like asking you to scratch your head and scratch your head all at the same time. But this may not strictly hold true for several reasons:
    1. your DB should scale, i.e. handle two simultaneous requests faster than two concurrent requests. However, this will probably not be true of 300 simultaneous requests being faster than 300 concurrent (or 50 * 6-concurrent requests).
    2. if you are in a multi-CPU environment then some concurrentcy improvements would be expected (more hands for head scratching).
    3. your application does two things: reads a DB and sends a mail. While sending one mail, you should be albe to concurrently read the next record. i.e. concurrency is supported here, as you don't have resource contention here.
    So, you will probably get some benefit from threads. Adding too many will only slow you down, as there'll be too much time spend task switching, as you'll suffer resource contenion on the DB/mail server.
    I suggest that you run your program with several configurations, i.e. number of threads, and see what one gives the best results. For fast results, I'd suggests trying the following number of threads:
    1, 2, 4, 8, 16, 32, 64, 128, 256, ...
    when things start to slow down, you know where to search for your optimum thread number. You could also do with profiling your application if speed is a very pressing issue.
    Finally, one clarification: this is not OO. You could do multi-threading in a procedural environment.
    Good luck.
    if you are running on a multi-CPU environment, then the DB

  • Digital clock circuit

    hello!
    I am trying to build a digital clock circuit to count the time in hours,minutes and seconds( I use Multisim Power Pro 10).
    my first problem is that i was supposed to use CMOS CD4026(decade counters and 7-segment display drivers), but it doesn't exist in my library. So I tried to find a replacement and I got some(7490,74176,74292). But now I can't seem to figure out how to connect these so that I have the proper display. Can you please give me a hint?
       Thank you!

    Hi,
    There were a few problems with the circuit which is why the clock was not reseting at 3. I have modified the file. Please take a look and see. You will need to add a buffer between the second input and the AND gate because otherwise, the gate will trigger before the output has actually reached the desired state.
    I had to edit the delay time in the buffer to make it work of this circuit. To edit the delay time, double-click the Buffer and under the Value tab, click on Edit Model. You can change the rise time and fall time from this window.
    Hope this helps.
    Regards,
    Tayyab R,
    National Instruments.
    Attachments:
    NEW140712 mod.ms11 ‏545 KB

  • Digital clock

    I am trying to simulate a digital clock for counting 0-60 seconds using two seven seg displays two 7447 two 7493 and two clock generators on Multisim but the problem is i cannot workout the frequency input to be given to the two 7493 ic's connected to the displays through the two 7447 ic's please help
    Solved!
    Go to Solution.
    Attachments:
    Untitled.png ‏187 KB

    You should post to the multisim board. You can click on Options and request that the moderator move your question. It really had nothing to do with an NI digital I/O device.

  • Analog or Digital Clock in movie

    Hi,
    I am wanting to put a analog or digital clock in a video I am making for a class. I doesn't have to show the real time but hopefully it will have hours:minutes:seconds. Does anyone know where I can get one?
    Thanks.
    Andy

    If you have access to After Effects, you can do it under the "Textt" filter, then click on "Numbers." Pick a font, and then you can set what you need under the format tab. That should square you away. Or you could make your own digital clock with numbers in FCP, or with photoshop layers and set it up on a timeline manually. You could set up your incoming clip for one frame and just drop in the layers and theyll drop in sequence instead of dropping in every number one by one. All you would have to do is go through the trouble of making 01-59. Hope that helps.

  • Digital Clock in ADF

    Hi All,
    How can I add the digital clock in ADF( Studio Edition Version 11.1.1.1.0 /Build JDEVADF_11.1.1.1.0_GENERIC_090615.0017.5407/)
    Version Details :
    ADF Business Components     11.1.1.54.7
    CVS Version     Internal to Oracle JDeveloper 11g (client-only)
    Java(TM) Platform     1.6.0_11
    Oracle IDE     11.1.1.1.33.54.07
    Versioning Support     11.1.1.1.33.54.07
    Please help me....
    Regards
    Shekhar

    How can I Show the Current Date Time In a page. Time will be changeable.here is an example:
    jspx
          <af:form id="f1">
            <af:poll id="p1"  interval="1000" immediate="true"
                     pollListener="#{viewScope.clockBKB.pollListener}"/>
                <af:outputText value="Time:#{viewScope.clockBKB.strTime}" id="ot1" partialTriggers="p1"/>
          </af:form>backing bean (ClockBKB.java)
    import java.util.Date;
    import org.apache.myfaces.trinidad.event.PollEvent;
    public class ClockBKB {
        private String strTime;
        public ClockBKB() {
        public void pollListener(PollEvent pollEvent) {
            strTime = new Date().toString();
        public String getStrTime() {
            return strTime;
    }You may want to format the date as per your requirements.
    regards
    srini

Maybe you are looking for

  • How to delete the entries from the transport request

    i need to delete the entries programatically from the transport request for all the entries which is exists in the package for the tables e070 and e071.

  • Windows 8 install on new SSD to replace broken HD

    My 500GB HD failed on my HP Envy Touchsmart Sleekbook.  Before it failed i created a recovery USB stick.  I replaced the 500GB HD with a new, blank 240GB SSD.  The recovery from my USB stick failed.  I ordered new recovery USB stick from HP.  Recover

  • RE: Java on XP Pro

    Hi, I was not sure where to put this but here it is anyway. I have been having problems with my Java applications lately on my Windows XP Pro SP2 OS. I have downloaded and installed Java 2 Platform EE, Java 2 SDK, Net Beans IDE 4.1 & Java Runtime Env

  • Rights to Inventory Custom Reports

    Hi On our ZCM zone (recently upgraded to ZCM 11.2.1) only the "Administrator" can view Inventory Custom Reports. All other admins (including superadmins) see nothing in the Inventory Custom Reports list. If they create a new report the name is accept

  • Lucid keypad locks and gets into a loop

    Does anyone else have a problem with putting a pin # in the Lucid to lock the screen?  After entering my pin it works at first, but I usually shut it down overnight to conserve the battery - usually the next day when I try to put the pin it, it accep