You are here:   HomeJava ProgrammingSwingshowInputDialog Java Swing Example
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(Color.green, 5));

        msg.setVisible(true);

        try

          {

             Thread.sleep(timeDuration);

          }

          catch(Exception e) {}

          msg.setVisible(false);

     }

      public static void main(String args[])

      {

          displayMessage(8000);

          System.exit(0);

      }

}

The output of the program is shown in Figure

                      JWindow class in Java Swing Example





Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes 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.



What's New and Popular





Popular Article