Example usage for java.awt SplashScreen close

List of usage examples for java.awt SplashScreen close

Introduction

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

Prototype

public void close() throws IllegalStateException 

Source Link

Document

Hides the splash screen, closes the window, and releases all associated resources.

Usage

From source file:com.rinke.solutions.pinball.PinDmdEditor.java

/**
 * Open the window./*from w w w. j  a  v a 2 s  .co  m*/
 * 
 * @param args
 */
public void open(String[] args) {

    CmdLineParser parser = new CmdLineParser(this);
    try {
        parser.parseArgument(args);
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        // print the list of available options
        parser.printUsage(System.err);
        System.err.println();
        System.exit(1);
    }

    display = Display.getDefault();
    shell = new Shell();
    fileChooserUtil = new FileChooserUtil(shell);
    paletteHandler = new PaletteHandler(this, shell);
    aniAction = new AnimationActionHandler(this, shell);

    createContents(shell);

    createNewProject();

    paletteComboViewer.getCombo().select(0);
    paletteTool.setPalette(activePalette);

    animationHandler = new AnimationHandler(playingAnis, clock, dmd);

    animationHandler.setScale(scale);
    animationHandler.setEventHandler(this);
    animationHandler.setMask(project.mask);

    createBindings();

    SplashScreen splashScreen = SplashScreen.getSplashScreen();
    if (splashScreen != null) {
        splashScreen.close();
    }

    shell.open();
    shell.layout();
    shell.addListener(SWT.Close, e -> {
        e.doit = dirtyCheck();
    });

    GlobalExceptionHandler.getInstance().setDisplay(display);
    GlobalExceptionHandler.getInstance().setShell(shell);
    new Label(shell, SWT.NONE);
    new Label(shell, SWT.NONE);
    new Label(shell, SWT.NONE);
    new Label(shell, SWT.NONE);

    display.timerExec(animationHandler.getRefreshDelay(), cyclicRedraw);

    processCmdLine();

    int retry = 0;
    while (true) {
        try {
            log.info("entering event loop");
            while (!shell.isDisposed()) {
                if (!display.readAndDispatch()) {
                    display.sleep();
                }
            }
            System.exit(0);
        } catch (Exception e) {
            GlobalExceptionHandler.getInstance().showError(e);
            log.error("unexpected error: {}", e);
            if (retry++ > 10)
                System.exit(1);
        }
    }

}