import [Link].
BorderLayout;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class Digital_clock extends JFrame {
private JLabel timeLabel;
private JLabel dateLabel;
public Digital_clock() {
setTitle("Digital Clock");
setSize(500, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
// Create a panel to hold the time and date labels
JPanel panel = new JPanel();
[Link]([Link](20, 20, 20, 20));
[Link](new BorderLayout());
// Create a label to display the time
timeLabel = new JLabel();
[Link](new Font("Arial", [Link], 60));
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
// Create a label to display the date
dateLabel = new JLabel();
[Link](new Font("Arial", [Link], 20));
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
// Add the time and date labels to the panel
[Link](timeLabel, [Link]);
[Link](dateLabel, [Link]);
// Set the panel's background color
[Link]([Link]);
// Add the panel to the frame
add(panel);
// Use a Timer to update the time and date labels every second
Timer timer = new Timer(1000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateTimeAndDate();
}
});
[Link]();
}
private void updateTimeAndDate() {
// Get the current time and format it
Calendar calendar = [Link]();
SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
String time = [Link]([Link]());
// Get the current date and format it
SimpleDateFormat dateFormatter = new SimpleDateFormat("EEE, MMM dd, yyyy");
String date = [Link]([Link]());
// Update the time and date labels
[Link](time);
[Link](date);
}
public static void main(String[] args) {
Digital_clock clock = new Digital_clock();
[Link](true);
}
}