by Dinesh Thakur Category: Swing

The JWindow class is used to create a window which does not have any toolbar, border or window management buttons. This type of window is usually used to display messages like welcome messages, Copyright information, etc. The commonly used of constructor of JWindow class is as follows.

JWindow ()

Example: A program to demonstrate the use of JWindow class

import java.awt.*;

import javax.swing.*;

class Message


     public static void displayMessage(int timeDuration)


        JWindow msg =new JWindow();

        JPanel panel= (JPanel)msg.getContentPane();

        int width = 350, height = 150;

        int x = 50, y = 50;

        msg.setBounds(x, y, width, height);

        JLabel welcome= new JLabel("Welcome! to Java Programming",JLabel. CENTER);

        welcome.setFont(new Font("Times New Roman", Font.BOLD, 20));

        panel.add(welcome, BorderLayout.CENTER);

        panel.setBorder(BorderFactory.createLineBorder(, 5));






          catch(Exception e) {}



      public static void main(String args[])






The output of the program is shown in Figure

                      JWindow class in Java Swing Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles