Java clock app 🕓

Veröffentlicht am: 06 September 2020
auf dem Kanal: Bro Code
80,974
2.3k

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

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

//https://docs.oracle.com/javase/7/docs...
//---------------------------------------------------------------
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();
}
}
}
}
//---------------------------------------------------------------


Auf dieser Seite können Sie das Online-Video Java clock app 🕓 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Bro Code 06 September 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 80,974 Mal angesehen und es wurde von 2.3 tausend den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!