Java Code Examples for java.awt.SplashScreen#getSplashScreen()
The following examples show how to use
java.awt.SplashScreen#getSplashScreen() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Main.java From gsn with GNU General Public License v3.0 | 6 votes |
private static void updateSplashIfNeeded(String message[]) { boolean headless_check = isHeadless(); if (!headless_check) { SplashScreen splash = SplashScreen.getSplashScreen(); if (splash == null) return; if (splash.isVisible()) { //Get a graphics overlay for the splash screen Graphics2D g = splash.createGraphics(); //Do some drawing on the graphics object //Now update to the splash screen g.setComposite(AlphaComposite.Clear); g.fillRect(0,0,400,70); g.setPaintMode(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setColor(Color.BLACK); g.setFont(new Font("Arial",Font.BOLD,11)); for (int i=0;i<message.length;i++) g.drawString(message[i], 13, 16*i+10); splash.update(); } } }
Example 2
Source File: RESTUtil.java From rest-client with Apache License 2.0 | 6 votes |
/** * * @Title : closeSplashScreen * @Description: close splash screen * @Param : * @Return : void * @Throws : */ public static void closeSplashScreen() { SplashScreen ss = SplashScreen.getSplashScreen(); if (null == ss) { return; } try { ss.close(); } catch(Exception e) { // Ignore this exception } }
Example 3
Source File: MultiResolutionSplashTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 4
Source File: MultiResolutionSplashTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 5
Source File: UnixMultiResolutionSplashTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 6
Source File: MultiResolutionSplashTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 7
Source File: MultiResolutionSplashTest.java From hottub with GNU General Public License v2.0 | 6 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 8
Source File: EarthApp.java From collect-earth with MIT License | 5 votes |
private static void closeSplash() { try { final SplashScreen splash = SplashScreen.getSplashScreen(); if (splash != null) { splash.close(); } } catch (final IllegalStateException e) { logger.error("Error closing the splash window", e); //$NON-NLS-1$ } }
Example 9
Source File: TinkerTimeLauncher.java From TinkerTime with GNU General Public License v3.0 | 5 votes |
@Override public void run() { // Get App Icons ImageManager imageManager = new ImageManager(); List<Image> appIcons = new ArrayList<Image>(); appIcons.add(imageManager.getImage("icon/app/icon 128x128.png")); appIcons.add(imageManager.getImage("icon/app/icon 64x64.png")); appIcons.add(imageManager.getImage("icon/app/icon 32x32.png")); appIcons.add(imageManager.getImage("icon/app/icon 16x16.png")); // Hide Splash Screen so the JFrame does not hide when appearing SplashScreen s = SplashScreen.getSplashScreen(); if (s != null){ s.close(); } // Initialize Frame JFrame frame = new JFrame(TinkerTimeLauncher.FULL_NAME); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.setIconImages(appIcons); frame.setJMenuBar(menuBar); frame.add(toolBar, BorderLayout.NORTH); frame.add(modSelectorPanelController.getComponent(), BorderLayout.CENTER); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.toFront(); }
Example 10
Source File: DBrowser.java From Rel with Apache License 2.0 | 5 votes |
private static boolean executeSplashInteractor(Runnable splashInteraction) { if (SplashScreen.getSplashScreen() == null) return false; // Non-MacOS if (!Util.isMac()) { splashInteraction.run(); closeSplash(); return true; } // MacOS Display display = Display.getDefault(); final Semaphore sem = new Semaphore(0); Thread splashInteractor = new Thread(() -> { splashInteraction.run(); sem.release(); display.asyncExec(() -> {}); closeSplash(); }); splashInteractor.start(); // Interact with splash screen while (!display.isDisposed() && !sem.tryAcquire()) if (!display.readAndDispatch()) display.sleep(); return true; }
Example 11
Source File: AppSplashScreen.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** Splash initialise. */ public static void splashInit() { splashScreenObj = SplashScreen.getSplashScreen(); if (splashScreenObj != null) { createTextArea(); // create the Graphics environment for drawing status info splashGraphics = splashScreenObj.createGraphics(); splashGraphics.setFont(font); // Display the version number splashText(getVersionString()); } }
Example 12
Source File: Main.java From gsn with GNU General Public License v3.0 | 5 votes |
private static void closeSplashIfneeded() { if (isHeadless()) return; SplashScreen splash = SplashScreen.getSplashScreen(); //Check if we have specified any splash screen if (splash == null) { return; } if (splash.isVisible()) splash.close(); }
Example 13
Source File: MultiResolutionSplashTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); if(splashBounds.width != IMAGE_WIDTH){ throw new RuntimeException( "SplashScreen#getBounds has wrong width"); } if(splashBounds.height != IMAGE_HEIGHT){ throw new RuntimeException( "SplashScreen#getBounds has wrong height"); } Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 14
Source File: MultiResolutionSplashTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); if (splashBounds.width != IMAGE_WIDTH) { throw new RuntimeException( "SplashScreen#getBounds has wrong width"); } if (splashBounds.height != IMAGE_HEIGHT) { throw new RuntimeException( "SplashScreen#getBounds has wrong height"); } Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 15
Source File: MultiResolutionSplashTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); if(splashBounds.width != IMAGE_WIDTH){ throw new RuntimeException( "SplashScreen#getBounds has wrong width"); } if(splashBounds.height != IMAGE_HEIGHT){ throw new RuntimeException( "SplashScreen#getBounds has wrong height"); } Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 16
Source File: MultiResolutionSplashTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); if(splashBounds.width != IMAGE_WIDTH){ throw new RuntimeException( "SplashScreen#getBounds has wrong width"); } if(splashBounds.height != IMAGE_HEIGHT){ throw new RuntimeException( "SplashScreen#getBounds has wrong height"); } Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 17
Source File: MultiResolutionSplashTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static void testSplash(ImageInfo test) throws Exception { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen == null) { throw new RuntimeException("Splash screen is not shown!"); } Graphics2D g = splashScreen.createGraphics(); Rectangle splashBounds = splashScreen.getBounds(); int screenX = (int) splashBounds.getCenterX(); int screenY = (int) splashBounds.getCenterY(); if(splashBounds.width != IMAGE_WIDTH){ throw new RuntimeException( "SplashScreen#getBounds has wrong width"); } if(splashBounds.height != IMAGE_HEIGHT){ throw new RuntimeException( "SplashScreen#getBounds has wrong height"); } Robot robot = new Robot(); Color splashScreenColor = robot.getPixelColor(screenX, screenY); float scaleFactor = getScaleFactor(); Color testColor = (1 < scaleFactor) ? test.color2x : test.color1x; if (!compare(testColor, splashScreenColor)) { throw new RuntimeException( "Image with wrong resolution is used for splash screen!"); } }
Example 18
Source File: KSE.java From keystore-explorer with GNU General Public License v3.0 | 4 votes |
/** * Start the KeyStore Explorer application. Takes one optional argument - * the location of a KeyStore file to open upon startup. * * @param args * the command line arguments */ public static void main(String args[]) { try { // To take affect these must be set before the splash screen is instantiated if (OperatingSystem.isMacOs()) { setAppleSystemProperties(); } else if (OperatingSystem.isWindows7() || OperatingSystem.isWindows8() || OperatingSystem.isWindows10()) { String appId = props.getString("KSE.AppUserModelId"); Shell32 shell32 = Native.loadLibrary("shell32", Shell32.class); shell32.SetCurrentProcessExplicitAppUserModelID(new WString(appId)).longValue(); } else if (OperatingSystem.isLinux()) { fixAppClassName(); } setInstallDirProperty(); SplashScreen splash = SplashScreen.getSplashScreen(); updateSplashMessage(splash, res.getString("KSE.LoadingApplicationSettings.splash.message")); ApplicationSettings applicationSettings = ApplicationSettings.getInstance(); setCurrentDirectory(applicationSettings); String languageCode = applicationSettings.getLanguage(); if (!ApplicationSettings.SYSTEM_LANGUAGE.equals(languageCode)) { Locale.setDefault(new Locale(languageCode)); } updateSplashMessage(splash, res.getString("KSE.InitializingSecurity.splash.message")); initialiseSecurity(); // list of files to open after start List<File> parameterFiles = new ArrayList<>(); for (String arg : args) { File parameterFile = new File(arg); if (parameterFile.exists()) { parameterFiles.add(parameterFile); } } // Create application GUI on the event handler thread updateSplashMessage(splash, res.getString("KSE.CreatingApplicationGui.splash.message")); SwingUtilities.invokeLater(new CreateApplicationGui(applicationSettings, splash, parameterFiles)); } catch (Throwable t) { DError dError = new DError(new JFrame(), t); dError.setLocationRelativeTo(null); dError.setVisible(true); System.exit(1); } }
Example 19
Source File: DBrowser.java From Rel with Apache License 2.0 | 4 votes |
private static void closeSplash() { SplashScreen splash = SplashScreen.getSplashScreen(); if (splash != null) splash.close(); }
Example 20
Source File: DBrowser.java From Rel with Apache License 2.0 | 4 votes |
private static void launch(String[] args) { Display.setAppName(Version.getAppName()); Display.setAppVersion(Version.getVersion()); final Display display = new Display(); OpenDocumentEventProcessor openDocProcessor = new OpenDocumentEventProcessor(); display.addListener(SWT.OpenDocument, openDocProcessor); openDocProcessor.addFilesToOpen(args); if (Util.isMac()) executeSplashInteractor(() -> { try { Thread.sleep(300); } catch (InterruptedException e1) { } }); try { Class.forName("org.reldb.rel.Rel"); localRel = true; } catch (ClassNotFoundException cnfe) { localRel = false; } OSSpecific.launch(Version.getAppName(), event -> quit(), event -> new AboutDialog(shell).open(), event -> new Preferences(shell).show() ); if (!Util.isMac()) { SplashScreen splash = SplashScreen.getSplashScreen(); if (splash != null && localRel && !Preferences.getPreferenceBoolean(PreferencePageGeneral.SKIP_DEFAULT_DB_LOAD)) { Graphics2D gc = splash.createGraphics(); Rectangle rect = splash.getBounds(); int barWidth = rect.width - 20; int barHeight = 10; Rectangle progressBarRect = new Rectangle(10, rect.height - 20, barWidth, barHeight); gc.draw3DRect(progressBarRect.x, progressBarRect.y, progressBarRect.width, progressBarRect.height, false); gc.setColor(Color.green); (new Thread(() -> { while (SplashScreen.getSplashScreen() != null) { int percent = Loading.getPercentageOfExpectedMessages(); int drawExtent = Math.min(barWidth * percent / 100, barWidth); gc.fillRect(progressBarRect.x, progressBarRect.y, drawExtent, barHeight); splash.update(); try { Thread.sleep(250); } catch (InterruptedException e) { } } })).start(); } } shell = createShell(); shell.setImage(IconLoader.loadIcon("RelIcon")); shell.setImages(loadIcons(display)); shell.setText(Version.getAppID()); shell.addListener(SWT.Close, e -> { shell.dispose(); }); shell.addDisposeListener(e -> quit()); shell.layout(); Loading.start(); Core.launch(openDocProcessor, shell); if (!Util.isMac()) closeSplash(); shell.open(); while (!display.isDisposed()) { try { if (!display.readAndDispatch()) display.sleep(); } catch (Throwable t) { System.out.println("DBrowser: Exception: " + t); t.printStackTrace(); } } }