Java clock app 🕓

Поділитися
Вставка
  • Опубліковано 14 січ 2025

КОМЕНТАРІ • 141

  • @BroCodez
    @BroCodez  4 роки тому +37

    //docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#text
    //---------------------------------------------------------------
    public class Main {
    public static void main(String[] args) {

    new MyFrame();
    }
    }
    //---------------------------------------------------------------
    import java.awt.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    public class MyFrame extends JFrame{

    Calendar calendar;
    SimpleDateFormat timeFormat;
    SimpleDateFormat dayFormat;
    SimpleDateFormat dateFormat;
    JLabel timeLabel;
    JLabel dayLabel;
    JLabel dateLabel;
    String time;
    String day;
    String date;
    MyFrame(){
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setTitle("My Clock Program");
    this.setLayout(new FlowLayout());
    this.setSize(350,200);
    this.setResizable(false);

    timeFormat = new SimpleDateFormat("hh:mm:ss a");
    dayFormat = new SimpleDateFormat("EEEE");
    dateFormat = new SimpleDateFormat("MMMMM dd, yyyy");

    timeLabel = new JLabel();
    timeLabel.setFont(new Font("Verdana",Font.PLAIN,50));
    timeLabel.setForeground(new Color(0x00FF00));
    timeLabel.setBackground(Color.black);
    timeLabel.setOpaque(true);

    dayLabel = new JLabel();
    dayLabel.setFont(new Font("Ink Free",Font.PLAIN,35));

    dateLabel = new JLabel();
    dateLabel.setFont(new Font("Ink Free",Font.PLAIN,25));


    this.add(timeLabel);
    this.add(dayLabel);
    this.add(dateLabel);
    this.setVisible(true);

    setTime();
    }

    public void setTime() {
    while(true) {
    time = timeFormat.format(Calendar.getInstance().getTime());
    timeLabel.setText(time);

    day = dayFormat.format(Calendar.getInstance().getTime());
    dayLabel.setText(day);

    date = dateFormat.format(Calendar.getInstance().getTime());
    dateLabel.setText(date);

    try {
    Thread.sleep(1000);
    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }
    }
    //---------------------------------------------------------------

    • @harsha4048
      @harsha4048 3 роки тому

      @Prashik Menka Valmik Indase eclipse bro

    • @mxh7aa
      @mxh7aa 3 роки тому

      Please make a video about clock timer in javafx

    • @joyceasante8292
      @joyceasante8292 Рік тому

      Practicing...
      public class Main
      {
      public static void main(String[] args) {
      new MyFrame();
      }
      }
      *******************
      import java.text.*;
      import java.time.*;
      import java.awt.*;
      import java.util.*;
      import javax.swing.*;
      public class MyFrame extends JFrame
      {
      Calendar Calendar;
      SimpleDateFormat timeFormat;
      SimpleDateFormat dayFormat;
      SimpleDateFormat dateFormat;
      JLabel timeLabel;
      JLabel dayLabel;
      JLabel dateLabel;
      String time;
      String day;
      String date;
      MyFrame ()
      {
      this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
      this.setTitle ("Clock App");
      this.setLayout (new FlowLayout ());
      this.setSize (400, 280);
      this.setResizable (false);
      timeFormat = new SimpleDateFormat ("hh:mm:ss a");
      dayFormat = new SimpleDateFormat ("EEEE");
      dateFormat = new SimpleDateFormat ("MMMMM dd, yyyy");
      timeLabel = new JLabel ();
      timeLabel.setFont (new Font ("Sans Seriff", Font.PLAIN, 18));
      timeLabel.setForeground (Color.red);
      timeLabel.setBackground (Color.black);
      timeLabel.setOpaque (true);
      dayLabel = new JLabel ();
      dayLabel.setFont (new Font ("Helvetica", Font.PLAIN, 20));
      dateLabel = new JLabel ();
      dateLabel.setFont (new Font ("Helvetica", Font.PLAIN, 20));
      this.add (timeLabel);
      this.add (dayLabel);
      this.add (dateLabel);
      this.setVisible (true);
      setTime ();
      }
      public void setTime ()
      {
      while (true)
      {
      time = timeFormat.format (Calendar.getInstance ().getTime ());
      timeLabel.setText (time);
      day = dayFormat.format (Calendar.getInstance ().getTime ());
      dayLabel.setText (day);
      date = dateFormat.format (Calendar.getInstance ().getTime ());
      dateLabel.setText (date);
      try
      {
      Thread.sleep (1000);
      }
      catch (InterruptedException e)
      {
      e.printStackTrace ();
      }
      }
      }
      }

  • @brianne2579
    @brianne2579 3 роки тому +6

    I hope you can read this to cheer you up. I've watched a lot of your videos and it help me a lot. I saved some of them on my JAVA playlist to be accessed quickly when I forgot something, It really helped me a lot. Then I've realized that I didn't subscribed to you. I just did now and I just want to say thank you so much, It helped me a lot. Hope you make more videos that will help someone in the future.

  • @mxh7aa
    @mxh7aa 3 роки тому +5

    Man...you know exactly what i need everytime i search for help and i found your videos, very helpful
    Respect 💪

  • @czg7479
    @czg7479 2 роки тому +1

    Support from fans. Please keep doing this kind of tutorial!

  • @JordantheComputerScientist
    @JordantheComputerScientist 4 роки тому +9

    This channel is the reason I'm still trying to learn. thanks

    • @BroCodez
      @BroCodez  4 роки тому +6

      You can do it Jordan!

    • @JordantheComputerScientist
      @JordantheComputerScientist 4 роки тому

      @@BroCodez I made a video creating my first GUI and I used a lot of what you taught me and created a counter GUI. I hope your channel blows up.

  • @yibyul2025
    @yibyul2025 Рік тому +3

    The setTime(); method actually works even without the Thread.sleep(1000); as long as the code is inside the while loop. The timeFormat will move each second for me.
    Anyway. Big thanks for this!

  • @hdjabs1950
    @hdjabs1950 2 роки тому +1

    sometimes i click on a video that i know im not equipped for, but i just want to see what to expect in the future! and it excites me

  • @arshdeepsingh3749
    @arshdeepsingh3749 3 роки тому +1

    Thanks bro this chennal is very helpful for students and I am from INDIA

  • @kingolintv
    @kingolintv 5 місяців тому

    This tutorial is amazing this whole channel is! I am planning to do your 7 hour full java course

  • @miuwai6211
    @miuwai6211 3 роки тому +2

    You help me coding my first Java apps. Thank you very much.

  • @gmlohith6641
    @gmlohith6641 4 роки тому +2

    Awesome bro I'm watching your videos regularly. great work. thanks a lot for the content.

    • @BroCodez
      @BroCodez  4 роки тому

      thanks for watching!

  • @JakeMGolle
    @JakeMGolle 3 роки тому

    This dude is really out here coding at 7 am on a Sunday, ha ha. Props.

  • @monikarathore4950
    @monikarathore4950 3 роки тому

    well explained it is easy to understand.

  • @manoshacooray5322
    @manoshacooray5322 2 роки тому

    Lovely 😍

  • @nalindugraphics3124
    @nalindugraphics3124 Рік тому

    This video is really helpfull bro. Subscribed 🤩

  • @aaronjohnson8403
    @aaronjohnson8403 3 роки тому

    Good video for developer

  • @mahrokhsadro843
    @mahrokhsadro843 3 роки тому

    a good java video with good English is a GEM!thxx

  • @rishabsingh-ml7df
    @rishabsingh-ml7df 2 роки тому +1

    your video was very helpful for me Respect Thank you It really helped me a lot. Then I've realized that I didn't subscribed to you. I just did now and I just want to say thank you so much, It helped me a lot. Hope you make more videos that will help someone in the future.

  • @rahulvarma3004
    @rahulvarma3004 2 роки тому

    excellent🤩

  • @guanyu8020
    @guanyu8020 3 роки тому +1

    Thank you Bro Code. You help me so much. I really appreciate what you have done here.

  • @ajitsomani4166
    @ajitsomani4166 Рік тому

    Thank you so much ,I watched two other videos on this program before this , but can't able to execute and understand the program .But this one was so easy to understand and I successfully completed this .Thank you once again.

  • @raviratnakar3803
    @raviratnakar3803 3 роки тому +1

    Awesome bro

  • @jeresue
    @jeresue 2 роки тому

    Brooo, you're good at explaining, amazing........

  • @tanviralam9798
    @tanviralam9798 4 роки тому +1

    I'm complete this code..thank you so much for your help

  • @TricksChronicals
    @TricksChronicals 3 роки тому +1

    cool

  • @par-feubr9420
    @par-feubr9420 3 роки тому

    Thanks for this great effort sir

  • @malicant123
    @malicant123 Рік тому

    Thanks for the tutorial.

  • @beatztito
    @beatztito 3 роки тому

    Good job

  • @ozifirebrand
    @ozifirebrand 2 роки тому

    Niceeee

  • @rachitmittal448
    @rachitmittal448 Рік тому

    🤜🤜🤜

  • @kemann3815
    @kemann3815 3 роки тому

    Nice

  • @manipurihunabopa
    @manipurihunabopa Рік тому

    Hey, bro. You are amzing. Your every video turorial are so good. You make everything easy. You are a great teacher. How did you master such great teaching strategy? Could you make a separate tutorial on How to teach well?"
    I'd very appreciate it.

  • @deepdaddy1208
    @deepdaddy1208 4 роки тому +4

    Awesome vid bro

  • @jefferyjohnson2612
    @jefferyjohnson2612 3 роки тому +1

    //Great video :)

  • @wolanus
    @wolanus 4 роки тому +1

    Thanks Bro for the video. Great job!

  • @ashutoshsoni9723
    @ashutoshsoni9723 3 роки тому

    Thank you Bro Code i am learning Java from your channel

  • @attalaw36
    @attalaw36 3 роки тому

    very helpful thank you

  • @DiaborMagics
    @DiaborMagics 4 місяці тому

    Thanks for this. I've been trying to find how I can make a program simulate real-time but couldnt find anything until "java clock" landed me this video (and a bunch of showcases that explained nothing).
    I want to practise some things like classes and methods by making a tournament (selection, preliminaries, pool phase, knock-out phase and several different events will help me get a grasp on these concepts i think, in a fun way). but i wanted to do it with time limits per game like in real life, where during the game things can happen. for example football or beach volleyball etc, but I cant implement that without knowing how to process real time in java.
    ok gonna watch this now :)
    EDIT: I already see something I didn't know was possible a few seconds in. You just put new MyFrame(); but I thought you always have to name your instances. MyFrame blabla equals new MyFrame, etc.

  • @TOMSONSONES
    @TOMSONSONES 10 місяців тому

    can u specify the theme for ur editor , its so well colored !!

  • @KhmerTimeline
    @KhmerTimeline 8 місяців тому

    make alarm clokc , timer too , sir thanks

  • @eugenezuev7349
    @eugenezuev7349 6 місяців тому

    understandable, thanks

  • @Amangupta-rh7cy
    @Amangupta-rh7cy 4 роки тому

    Good bro

  • @loscricciolo88
    @loscricciolo88 2 роки тому

    Clear and useful as usual. Thanks!

  • @andreassorqvist6882
    @andreassorqvist6882 3 роки тому +2

    Great vid!! One question though that came up about extendability, how do you apply an alarm-setting to time-applications using the SimpleDateFormat?

  • @fredomambu7593
    @fredomambu7593 Рік тому

    It's a pure art

  • @mdmoinuddin6168
    @mdmoinuddin6168 2 роки тому

    Thank you sir

  • @-howto8493
    @-howto8493 4 роки тому

    Good

  • @bodipie2828
    @bodipie2828 3 роки тому +1

    how do I center the window when running the program (starts in the center of the screen)

  • @eduardandreihondrea4884
    @eduardandreihondrea4884 4 роки тому

    You are awesome. 👏

  • @trickysachin
    @trickysachin 3 роки тому

    👍

  • @athrvajadhav8620
    @athrvajadhav8620 Рік тому

    Bro thanks 👍👍❤

  • @ChristianRodriguez-tm3jg
    @ChristianRodriguez-tm3jg 2 роки тому

    Thanks bro... It just what i neer to create a planner app for practice... greetings 15/01/2023

  • @emdorsfm1625
    @emdorsfm1625 2 роки тому

    these vids are super helpfull thanks alot
    of and for the lasy people like me besides clicking on the src file and then clicking on file and then new class click all these: alt - shift - n and you will need to click on class

  • @tanviralam9798
    @tanviralam9798 4 роки тому +1

    Thank you... Bro code..... Love Bangladesh

  • @joshuaraymond4996
    @joshuaraymond4996 2 роки тому

    thanks for everything.

  • @denyserurangwa9581
    @denyserurangwa9581 Рік тому

    🤗

  • @uwucodes4419
    @uwucodes4419 3 роки тому

    Great vid!! One question though that came up about extendability, how do you apply an alarm-setting to time-applications using the SimpleDateFormat? (2)

  • @aqibishaq885
    @aqibishaq885 4 роки тому

    bro dudeu just awesome just sub ur channel today bring more java content

  • @aakashtiwari3677
    @aakashtiwari3677 3 роки тому +1

    How do I set Border color, width of the Frame ?

  • @vedanshisahay9179
    @vedanshisahay9179 2 роки тому

    Thanks ✨✨

  • @mehmetlehmann5601
    @mehmetlehmann5601 2 роки тому

    Thank you very much.

  • @trillius
    @trillius 2 роки тому +1

    Thanks man this was soo helpful!

  • @stanislavdimitrov1643
    @stanislavdimitrov1643 Рік тому

    Very nice video, thank you very much. Can this app be opened outside of Eclipse?

  • @edoardoromero
    @edoardoromero 3 роки тому

    thanks for this videos Bro! ;-)

  • @fahrulrozi7030
    @fahrulrozi7030 Рік тому

    thank you so much bro 🥰🥰

  • @oguzhantopaloglu9442
    @oguzhantopaloglu9442 4 роки тому

    amazing as usual

  • @kal-elzecco8948
    @kal-elzecco8948 2 роки тому

    Thankyou so much!! you help me a lot bro

  • @AwestruckEarl
    @AwestruckEarl Рік тому

    do newer version of ide have to run the code first? cuase it doesnt run at the 2 minute mark

  • @mlame95
    @mlame95 2 роки тому

    Thank you brohan

  • @JLSXMK8
    @JLSXMK8 3 роки тому

    I get it already! So, are the hex values of the format "0xRRGGBB" for the Color class (R = "Red", G = "Green", B = "Blue")? That's cool.

  • @dendrxx
    @dendrxx 3 роки тому

    Where are you importing from? When i do that in the code along it doesnt utilize that the import.

  • @BitCloud047
    @BitCloud047 3 роки тому

    awesome video bro!

  • @shibangi_.9263
    @shibangi_.9263 Рік тому

    It's in NetBeans or vscode?

  • @lengeschder
    @lengeschder 4 роки тому

    Thank you for this vid!

  • @Catthecar12
    @Catthecar12 2 роки тому +1

    in 2:31, i run test and reslut say "Error occurred during initialization of boot layer
    java.lang.module.FindException: Error reading module: C:\Users\cusie\eclipse-workspace\Clock\bin
    Caused by: java.lang.module.InvalidModuleDescriptorException: Main.class found in top-level directory (unnamed package not allowed in module" can u pls help me

  • @stephanieezat-panah7750
    @stephanieezat-panah7750 2 роки тому

    What I would like to see, is a separate file, a library of sorts, that can be called in other files.
    so, I can have several windows, that will call this method, to display across different windows

  • @hartsijaan4038
    @hartsijaan4038 3 роки тому

    Thank you so much.

  • @alaarajab3962
    @alaarajab3962 Рік тому

    Thank you

  • @monwil3296
    @monwil3296 4 роки тому

    Thank you Bro 😎.

  • @DannyBeamz123
    @DannyBeamz123 Рік тому

    This is like my second vid on coding i went from nothing to making this by following the vid and struggling for like 2-3 hours tryna find my mistakes...Was amazing when I found what I did wrong though :)

  • @MrLoser-ks2xn
    @MrLoser-ks2xn 2 роки тому

    Thanks

  • @ninhduongchan763
    @ninhduongchan763 2 роки тому

    How can I synchronize time between servers in a distributed system by java language?

  • @АЯШАВА-й3ш
    @АЯШАВА-й3ш 3 роки тому

    Cool bro)

  • @developerjunior446
    @developerjunior446 3 роки тому

    Super Broo!!!

  • @ReVitsXD
    @ReVitsXD 3 роки тому +1

    This help me a lot , but i got some problems here, when i use this clock.java for 2nd class then i called it on my main.java class the clock.java won't show anything kinda stuck in loop

  • @Maximiliano706
    @Maximiliano706 2 роки тому

    Thank you !

  • @_xshadow6531
    @_xshadow6531 2 роки тому

    Can I do this program on bluej?

  • @saedshaheen8451
    @saedshaheen8451 3 роки тому

    thanks

  • @mahdimehraz6275
    @mahdimehraz6275 3 роки тому

    Respect

  • @pratikkunde4047
    @pratikkunde4047 3 роки тому

    Bro how to use swing in intelj

  • @henryescobarmontoya8918
    @henryescobarmontoya8918 3 роки тому

    Thanks Bro Code

  • @AnsarAbbas-ed5ig
    @AnsarAbbas-ed5ig 2 роки тому

    Goo Bro Code 😁

  • @kadisxb2507
    @kadisxb2507 3 роки тому

    thank you and I end 3 conditions

  • @HarryPotter-bd2qb
    @HarryPotter-bd2qb 3 роки тому

    Arigato kamisama

  • @robertniyazoff2591
    @robertniyazoff2591 2 роки тому

    How would I call this in another file?

  • @retr0k964
    @retr0k964 4 роки тому

    Maybe the thought behind making the name of the month "MMMMM", was that the word month has 5 letters, thus the 5 M's? Just a guess.

  • @KevoTHRASHER
    @KevoTHRASHER Рік тому

    how to repaint the clock in JPanel

  • @mortaldietwice6507
    @mortaldietwice6507 4 роки тому +17

    System.out.println("thanks");

  • @tasneemayham974
    @tasneemayham974 Рік тому

    I have a question, please!
    I tried to make a frame that has two buttons (Stopwatch & Clock), when clicked would produce a new window with each of their respective programs. When I click the button of the stopwatch, it works just fine, but the clock doesn't . The window opens, but it's empty. What's more is that I can't exit out of it by clicking the x button. It's as if the Default operation was DO NOTHING.
    I tried to delete the while loop and everything in it by passing it as a comment. The clock frame closes. May anyone please tell me why this is so?
    AND THANK YOU ALWAYS, BROO!

    • @lazyhashi854
      @lazyhashi854 Рік тому

      same problem T,T .....did you solve it??

    • @tasneemayham974
      @tasneemayham974 Рік тому

      @@lazyhashi854 No! I tried a lot. What did you try to fix it? Maybe we can figure something out together.

  • @martincerdahernandez2653
    @martincerdahernandez2653 3 роки тому

    Muy bueno :)