/* * Copyright (C) 2014 Vinu K.N * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.domainmath.gui; import java.awt.Image; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.SwingWorker; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; /** * * @author Vinu K.N */ public class SplashFrame extends javax.swing.JFrame { public java.net.URL imgURL = getClass().getResource("/org/domainmath/gui/resources/DomainMath.png"); public Image icon = Toolkit.getDefaultToolkit().getImage(imgURL); private String[] args; /** * Creates new form SplashFrame */ //TO DO: do all operations in MainFrame start here. public SplashFrame(String args[]) { this.args=args; initComponents(); setIconImage(icon); this.setLocationRelativeTo(null); (new SplashTask()).execute(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setAlwaysOnTop(true); setBackground(null); setUndecorated(true); setResizable(false); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/domainmath/gui/resources/Splash.png"))); // NOI18N getContentPane().add(jLabel1, java.awt.BorderLayout.CENTER); pack(); }// </editor-fold>//GEN-END:initComponents private class SplashTask extends SwingWorker<Void, Void> { @Override protected Void doInBackground() { int delay = 5000; //milliseconds ActionListener taskPerformer = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { dispose(); } }; javax.swing.Timer t= new javax.swing.Timer(delay, taskPerformer); t.setRepeats(false); t.start(); return null; } @Override protected void done() { try { int delay = 5000; //milliseconds ActionListener taskPerformer = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { MainFrame mainFrame = new MainFrame(args); mainFrame.setLocationRelativeTo(null); mainFrame.setVisible(true); } }; javax.swing.Timer t= new javax.swing.Timer(delay, taskPerformer); t.setRepeats(false); t.start(); } catch (Exception ignore) { } } } /** * @param args the command line arguments */ public static void main(String args[]) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new SplashFrame(args).setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; // End of variables declaration//GEN-END:variables }