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