javacodex.com
Java Examples
Java Examples
memu home questions

JWindow

Like a JFrame, a JWindow is another top-level container. It is as an undecorated JFrame. It does not have features like a title bar, windows menu, etc. It is not a very commonly used top-level container. You can use it as a splash window that displays once when the application is launched and then automatically disappears after a few seconds.

Source: (JWindowExample.java)

import java.awt.*;
import javax.swing.*;
 
public class JWindowExample {
 
  public static void main(String[] args) {
 
    JWindow window = new JWindow();
 
    // place window in the midle of the screen
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int width = 100;
    int height = 50;
    window.setBounds(screen.width/2, screen.height/2, width, height);
 
    JLabel label = new JLabel("Hello");
    window.add(label);
 
    window.setVisible(true);
  }
}
 

Output:

Output



Contact: javacodex@yahoo.com