DEV Community

sadiul hakim
sadiul hakim

Posted on

4 4

Hello World in java swing...

Hello guys today i am going to show you how you can print "Hello World" in java swing.

Now, what is java swing?

ANS : Swing is a GUI widget toolkit for Java. It is part of Oracle's Java Foundation Classes (JFC) – an API for providing a graphical user interface (GUI) for Java programs. Swing was developed to provide a more sophisticated set of GUI components than the earlier Abstract Window Toolkit (AWT)

Let's get started...

First of all you need to create a general class inside you package.

package com.hakim;

public class HelloWorld {
    public static void main(String[] args) {

    }
}

Enter fullscreen mode Exit fullscreen mode

Then you need to import JOptionPane from 'javax.swing' package.

import javax.swing.JOptionPane;
Enter fullscreen mode Exit fullscreen mode

Then you need to write this line in your main method.

 JOptionPane.showMessageDialog(null,"Hello World.");
Enter fullscreen mode Exit fullscreen mode

That is it.Easy,Right?

Retry later

Top comments (0)

Retry later

AWS GenAI Live!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️