Java clock app 🕓

preview_player
Показать описание
Java, clock, program, app, swing, GUI, tutorial, beginners,

#Java #clock #program #app #swing #GUI #tutorial #beginners

//---------------------------------------------------------------
public class Main {

public static void main(String[] args) {

new MyFrame();
}
}
//---------------------------------------------------------------

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(){

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

timeLabel = new JLabel();

dayLabel = new JLabel();

dateLabel = new JLabel();



setTime();
}

public void setTime() {
while(true) {



try {
} catch (InterruptedException e) {
// TODO Auto-generated catch block
}
}
}
}
//---------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор


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.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 dd, yyyy");

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

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 =
timeLabel.setText(time);

day =
dayLabel.setText(day);

date =
dateLabel.setText(date);

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

BroCodez
Автор

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.

brianne
Автор

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!

yibyul
Автор

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

mxhaa
Автор

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

JordantheComputerScientist
Автор

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

czg
Автор

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

kingolintv
Автор

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

hdjabs
Автор

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

arshdeepsingh
Автор

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

miuwai
Автор

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.

DiaborMagics
Автор

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

gmlohith
Автор

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.

manipurihunabopa
Автор

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.

rishabsingh-mldf
Автор

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

mahrokhsadro
Автор

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.

ajitsomani
Автор

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

JakeMGolle
Автор

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

TOMSONSONES
Автор

well explained it is easy to understand.

monikarathore
Автор

This video is really helpfull bro. Subscribed 🤩

nalindugraphics