PageRenderTime 58ms CodeModel.GetById 44ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 1ms

/restart/restart/starter.java

http://myseriesproject.googlecode.com/
Java | 130 lines | 87 code | 18 blank | 25 comment | 0 complexity | fd1a9f25c707477ab6c263c6b4ed9ec0 MD5 | raw file
  1/*
  2 * To change this template, choose Tools | Templates
  3 * and open the template in the editor.
  4 */
  5
  6/*
  7 * starter.java
  8 *
  9 * Created on 27 Απρ 2011, 1:03:14 μμ
 10 */
 11package restart;
 12
 13import java.io.BufferedReader;
 14import java.io.File;
 15import java.io.IOException;
 16import java.io.InputStreamReader;
 17import java.util.logging.Level;
 18import java.util.logging.Logger;
 19
 20/**
 21 *
 22 * @author ssoldatos
 23 */
 24public class starter extends javax.swing.JFrame {
 25
 26  /** Creates new form starter */
 27  public starter() {
 28    initComponents();
 29    setLocationRelativeTo(null);
 30    setVisible(true);
 31    validate();
 32    repaint();
 33  }
 34
 35  /** This method is called from within the constructor to
 36   * initialize the form.
 37   * WARNING: Do NOT modify this code. The content of this method is
 38   * always regenerated by the Form Editor.
 39   */
 40  @SuppressWarnings("unchecked")
 41  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 42  private void initComponents() {
 43
 44    jPanel1 = new javax.swing.JPanel();
 45    jLabel1 = new javax.swing.JLabel();
 46    jProgressBar1 = new javax.swing.JProgressBar();
 47
 48    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
 49    setResizable(false);
 50    setUndecorated(true);
 51
 52    jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
 53
 54    jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD, jLabel1.getFont().getSize()+2));
 55    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
 56    jLabel1.setText("Restarting MySeries");
 57
 58    jProgressBar1.setIndeterminate(true);
 59
 60    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
 61    jPanel1.setLayout(jPanel1Layout);
 62    jPanel1Layout.setHorizontalGroup(
 63      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 64      .addGroup(jPanel1Layout.createSequentialGroup()
 65        .addContainerGap()
 66        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 67          .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
 68          .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE))
 69        .addContainerGap())
 70    );
 71    jPanel1Layout.setVerticalGroup(
 72      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 73      .addGroup(jPanel1Layout.createSequentialGroup()
 74        .addContainerGap()
 75        .addComponent(jLabel1)
 76        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
 77        .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
 78        .addContainerGap(19, Short.MAX_VALUE))
 79    );
 80
 81    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
 82    getContentPane().setLayout(layout);
 83    layout.setHorizontalGroup(
 84      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 85      .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 86    );
 87    layout.setVerticalGroup(
 88      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 89      .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 90    );
 91
 92    pack();
 93  }// </editor-fold>//GEN-END:initComponents
 94
 95  /**
 96   * @param args the command line arguments
 97   */
 98  public static void main(String args[]) {
 99    java.awt.EventQueue.invokeLater(new Runnable() {
100
101      public void run() {
102        new starter();
103      }
104    });
105    try {
106        Thread.sleep(2000);
107      } catch (InterruptedException ex) {
108        Logger.getLogger(starter.class.getName()).log(Level.SEVERE, null, ex);
109      }
110    go();
111  }
112  // Variables declaration - do not modify//GEN-BEGIN:variables
113  private javax.swing.JLabel jLabel1;
114  private javax.swing.JPanel jPanel1;
115  private javax.swing.JProgressBar jProgressBar1;
116  // End of variables declaration//GEN-END:variables
117
118  private static void go() {
119    String pathToApp = new File("myseriesproject.jar").getAbsolutePath();
120    File startingDir = new File("myseriesproject.jar").getAbsoluteFile().getParentFile();
121    String[] envp = null; // should inherit the environment
122    try {
123      Process p = Runtime.getRuntime().exec(new String[]{"java", "-jar", pathToApp}, envp, startingDir);
124      System.exit(0);
125    } catch (IOException ex) {
126      
127    } 
128    
129  }
130}