Results 1 to 5 of 5
  1. #1
    tascoa is offline Member
    Join Date
    Oct 2008
    Posts
    16
    Rep Power
    0

    Default reset screen / clock

    Hi, I want to create elementary clock:

    Java Code:
    int i = 0;
    
            while (i == 0) {
                Date da = new Date();
                
                System.out.printf(da.getHours() + ":" + da.getMinutes() + ":" + da.getSeconds());
                System.out.println();
            }
    Can me tell me anybody, how I reset the screen (re-write) this output.

    Thanks a lot for some tips.

    P.S. Excuse me about the loop with i variable. :)

  2. #2
    hadesflames is offline Member
    Join Date
    Apr 2009
    Posts
    7
    Rep Power
    0

    Default

    What exactly do you mean? You want to make like a watch where it updates the output as a second goes by and what not? if so you can't do this with system.out.print(); try using a JFrame
    Last edited by hadesflames; 07-06-2009 at 12:12 AM.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    You may wish to use a java.util.Timer object. While Java has no clear screen for the console, you can create an equivalent with enough System.out.println() statements.

  4. #4
    tascoa is offline Member
    Join Date
    Oct 2008
    Posts
    16
    Rep Power
    0

    Default re

    Thank You very much.

    I have:
    Java Code:
    JFrame jf = new JFrame();
            Date da = new Date();
            String str = new String(da.getHours() + ":" + da.getMinutes() + ":" + da.getSeconds());
            JTextField jtf = new JTextField(str);
    
            jf.add(jtf);
    
            jf.setVisible(true);
            jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
    and I want to re-write this. May I use a loop to re-write? Is there any other solutions?

  5. #5
    Manfizy's Avatar
    Manfizy is offline Senior Member
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    193
    Rep Power
    6

    Default

    You can use swing timer which will do all that for you. its very easy to use

    check out this :Java 2 Platform SE 5.0
    We Learn Through Mistakes..,
    Manfizy:rolleyes:

Similar Threads

  1. how to reset the IDE
    By kattavijay in forum NetBeans
    Replies: 7
    Last Post: 03-09-2009, 03:39 PM
  2. Blank Screen while navigating from one screen to another
    By mohana.krishna in forum Java Servlet
    Replies: 0
    Last Post: 03-03-2009, 05:03 PM
  3. How to use reset() method in struts
    By rakesh_n_mehta in forum Web Frameworks
    Replies: 1
    Last Post: 11-21-2008, 03:23 PM
  4. in struts reset was problem
    By sureshBabu in forum Web Frameworks
    Replies: 1
    Last Post: 05-07-2008, 03:26 PM
  5. reset query
    By dd_verni in forum JDBC
    Replies: 0
    Last Post: 11-21-2007, 03:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •