Example usage for java.awt SplashScreen getSize

List of usage examples for java.awt SplashScreen getSize

Introduction

In this page you can find the example usage for java.awt SplashScreen getSize.

Prototype

public Dimension getSize() throws IllegalStateException 

Source Link

Document

Returns the size of the splash screen window as a Dimension .

Usage

From source file:SplashScreenDemo.java

public static void main(String[] args) {
    SplashScreen splashScreen = SplashScreen.getSplashScreen();
    Dimension size = splashScreen.getSize();
    int borderDim = (int) (size.height * 0.05);
    Graphics g = splashScreen.createGraphics();
    g.setColor(Color.blue);//ww  w.j a  v  a  2s.co  m
    for (int i = 0; i < borderDim; i++)
        g.drawRect(i, i, size.width - 1 - i * 2, size.height - 1 - i * 2);

    FontMetrics fm = g.getFontMetrics();
    int sWidth = fm.stringWidth("Initializing...");
    int sHeight = fm.getHeight();
    if (sWidth < size.width && 2 * sHeight < size.height) {
        g.setColor(Color.blue);
        g.drawString("Initializing...", (size.width - sWidth) / 2, size.height - 2 * sHeight);
    }

    splashScreen.update();

    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
    }
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    SplashScreen splash = SplashScreen.getSplashScreen();
    Graphics2D g = (Graphics2D) splash.createGraphics();
    Dimension dim = splash.getSize();
    for (int i = 0; i < 100; i++) {
        g.setColor(Color.RED);/*from www  . j  a  v a  2s .  c o  m*/
        g.fillRect(50, 50, dim.width - 100, dim.height - 100);
        splash.update();
        try {
            Thread.sleep(250);
        } catch (InterruptedException ignored) {
        }
    }
    JFrame frame = new JFrame("Splash Me2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel("Hello, Splash", JLabel.CENTER);
    frame.add(label, BorderLayout.CENTER);
    frame.setSize(300, 95);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    SplashScreen splash = SplashScreen.getSplashScreen();
    Graphics2D g = (Graphics2D) splash.createGraphics();
    System.out.println(splash.getBounds());
    Dimension dim = splash.getSize();
    for (int i = 0; i < 100; i++) {
        g.setColor(Color.RED);//from   w ww.j ava 2  s  . c  o  m
        g.fillRect(50, 50, dim.width - 100, dim.height - 100);
        splash.update();
        try {
            Thread.sleep(250);
        } catch (InterruptedException ignored) {
        }
    }
    JFrame frame = new JFrame("Splash Me2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel("Hello, Splash", JLabel.CENTER);
    frame.add(label, BorderLayout.CENTER);
    frame.setSize(300, 95);
    frame.setVisible(true);
}