| 27 | |
| 28 | // private Splash(File imageFile, boolean hidpi) { |
| 29 | private Splash(File image2xFile) { |
| 30 | // Putting this inside try/catch because it's not essential, |
| 31 | // and it's definitely not essential enough to prevent startup. |
| 32 | try { |
| 33 | // change default java window icon to processing icon |
| 34 | processing.app.ui.Toolkit.setIcon(this); |
| 35 | } catch (Exception e) { |
| 36 | // ignored |
| 37 | } |
| 38 | |
| 39 | Image image2x = |
| 40 | Toolkit.getDefaultToolkit().createImage(image2xFile.getAbsolutePath()); |
| 41 | |
| 42 | MediaTracker tracker = new MediaTracker(this); |
| 43 | tracker.addImage(image2x, 0); |
| 44 | try { |
| 45 | tracker.waitForID(0); |
| 46 | } catch (InterruptedException ignored) { } |
| 47 | |
| 48 | if (tracker.isErrorID(0)) { // abort on failure |
| 49 | setSize(0,0); |
| 50 | System.err.println("Warning: SplashWindow couldn't load splash image."); |
| 51 | synchronized (this) { |
| 52 | notifyAll(); |
| 53 | } |
| 54 | } else { |
| 55 | final int wide = image2x.getWidth(this) / 2; |
| 56 | final int high = image2x.getHeight(this) / 2; |
| 57 | |
| 58 | JComponent comp = new JComponent() { |
| 59 | public void paintComponent(Graphics g) { |
| 60 | processing.app.ui.Toolkit.prepareGraphics(g); |
| 61 | g.drawImage(image2x, 0, 0, wide, high, this); |
| 62 | } |
| 63 | |
| 64 | public Dimension getPreferredSize() { |
| 65 | return new Dimension(wide, high); |
| 66 | } |
| 67 | }; |
| 68 | comp.setSize(wide, high); |
| 69 | setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); |
| 70 | getContentPane().add(comp); |
| 71 | setUndecorated(true); // before pack() |
| 72 | pack(); |
| 73 | setLocationRelativeTo(null); // center on screen |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | |
| 78 | /** Open a splash window using the specified image. */ |