My First Java Swing App that prints current date

This is my first java swing app that prints the current date in in JLabel component. Check out the code for this very simple program

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JComponent;
import java.util.Date;

public class SwingApp extends JFrame{

    public static void main(String args[]){
        new SwingApp();
    SwingApp() {
        JLabel jlbLabel = new JLabel();
        jlbLabel.setText("My First Swing App : " + " " + new Date().toString());

Compile the above program and the output of this would be as shown below


In Category: Java

Ravi Shankar

A Software developer and blogger who is always looking to provide technical help to the wider community.

Show 1 Comment

Leave a Comment

Get your free copies of the following tech guides by joining the Digital Answers mailing list.