Java clock app 🕓
Java, clock, program, app, swing, GUI, tutorial, beginners,
#Java #clock #program #app #swing #GUI #tutorial #beginners
//https://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();
}
}
}
}
//---------------------------------------------------------------
Видео Java clock app 🕓 канала Bro Code
#Java #clock #program #app #swing #GUI #tutorial #beginners
//https://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();
}
}
}
}
//---------------------------------------------------------------
Видео Java clock app 🕓 канала Bro Code
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Java stopwatch ⏱️Java text editor app 📓JavaScript: Understanding the Weird Parts - The First 3.5 HoursHow To Get Current Time in JavaCoding Challenge #71: MinesweeperJava Programming Tutorial - 36 - Time ClassJava calculator app 🖩How a Mechanical Watch WorksJava login system 👨💻JavaScript Pro Tips - Code This, NOT ThatJava quiz game ⌛Java pong game 🏓Creating Digital Clock using Java Swing | Timer Class | ThreadHow Not to Make Mobile GamesJava Access Modifiers - Learn Public, Private, Protected and DefaultJava tutorial for beginners + tips & tricks ☕ (NEW)Java KeyListener 🚀Java threads 🧵Java multithreading 🧶