diff --git a/gregrwgw.syjs b/gregrwgw.syjs new file mode 100644 index 0000000..76afcce --- /dev/null +++ b/gregrwgw.syjs @@ -0,0 +1,2 @@ +test +test \ No newline at end of file diff --git a/src/net/apocalypselabs/symat/CodeEditor.java b/src/net/apocalypselabs/symat/CodeEditor.java index c260d72..9b29a6f 100644 --- a/src/net/apocalypselabs/symat/CodeEditor.java +++ b/src/net/apocalypselabs/symat/CodeEditor.java @@ -63,13 +63,13 @@ public class CodeEditor extends javax.swing.JInternalFrame { private RSyntaxTextArea codeBox = new RSyntaxTextArea(); private RTextScrollPane sp; private String lastSaved = ""; - + private CompletionProvider jscomp = new CodeCompleter("js").getProvider(); private CompletionProvider pycomp = new CodeCompleter("py").getProvider(); private AutoCompletion jsac = new AutoCompletion(jscomp); private AutoCompletion pyac = new AutoCompletion(pycomp); - - private String filename = ""; + + private File filedata; /** * Creates new form CodeEditor @@ -109,7 +109,7 @@ public class CodeEditor extends javax.swing.JInternalFrame { formMouseClicked(evt); } }); - + jsac.install(codeBox); sp.setVisible(true); codeBox.setVisible(true); @@ -435,10 +435,10 @@ public class CodeEditor extends javax.swing.JInternalFrame { if (r == JFileChooser.APPROVE_OPTION) { try { File f = fc.getSelectedFile(); - codeBox.setText(readFile(f.toString(), StandardCharsets.UTF_8)); + codeBox.setText(FileUtils.readFile(f.toString())); isSaved = true; - filename = f.toString(); - lastSaved = codeBox.getText(); + filedata = f; + lastSaved = FileUtils.MD5(codeBox.getText()); setTitle("Editor - " + f.getName()); } catch (IOException ex) { JOptionPane.showInternalMessageDialog(this, @@ -455,8 +455,10 @@ public class CodeEditor extends javax.swing.JInternalFrame { */ public void openFileFromName(String file) { try { + Debug.println(file); File f = new File(file); - openString(readFile(f.toString(), StandardCharsets.UTF_8), f.getName(), true); + openString(FileUtils.readFile(f.getAbsolutePath()), + f.getAbsolutePath(), true); } catch (IOException ex) { JOptionPane.showInternalMessageDialog(this, "Error: Cannot load file: " + ex.getMessage()); @@ -472,8 +474,8 @@ public class CodeEditor extends javax.swing.JInternalFrame { private void openString(String data, String file, boolean saved) { codeBox.setText(data); isSaved = saved; - lastSaved = codeBox.getText(); - setTitle("Editor - " + file); + lastSaved = FileUtils.MD5(codeBox.getText()); + setTitle("Editor - " + (new File(file)).getName()); if (file.matches(".*\\.(js|mls|symt|syjs)")) { javascriptOption.setSelected(true); pythonOption.setSelected(false); @@ -487,7 +489,7 @@ public class CodeEditor extends javax.swing.JInternalFrame { jsac.uninstall(); pyac.install(codeBox); } - filename = file; + filedata = new File(file); } private void saveMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveMenuActionPerformed @@ -495,31 +497,27 @@ public class CodeEditor extends javax.swing.JInternalFrame { int r = fc.showSaveDialog(this); if (r == JFileChooser.APPROVE_OPTION) { try { - saveFile(codeBox.getText(), addSaveExt(fc.getSelectedFile().toString())); - filename = fc.getSelectedFile().toString(); + filedata = FileUtils.getFileWithExtension(fc); + FileUtils.saveFile(codeBox.getText(), filedata.getAbsolutePath(), true); + isSaved = true; + lastSaved = FileUtils.MD5(codeBox.getText()); + setTitle("Editor - " + + FileUtils.getFileWithExtension(fc).getName()); } catch (IOException ex) { JOptionPane.showInternalMessageDialog(this, "Error: Cannot save file: " + ex.getMessage()); } } } else { try { - saveFile(codeBox.getText(), addSaveExt(filename)); + FileUtils.saveFile(codeBox.getText(), filedata.getAbsolutePath(), true); } catch (IOException ex) { JOptionPane.showInternalMessageDialog(this, "Error: Cannot save file: " + ex.getMessage()); } } + Debug.println(filedata.toString()); + Debug.println(filedata.getAbsolutePath()); }//GEN-LAST:event_saveMenuActionPerformed - private String addSaveExt(String path) { - if (!path.matches(".*\\.(js|mls|symt|syjs|sypy|py)")) { - if (pythonOption.isSelected()) { - path += ".sypy"; - } else { - path += ".syjs"; - } - } - return path; - } private void saveAsMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsMenuActionPerformed isSaved = false; // Reset saved status, force dialog saveMenuActionPerformed(evt); @@ -550,7 +548,7 @@ public class CodeEditor extends javax.swing.JInternalFrame { execCode(lang); setRunning(false); } - + public void setRunning(boolean isRunning) { final boolean running = isRunning; SwingUtilities.invokeLater(new Runnable() { @@ -679,20 +677,9 @@ public class CodeEditor extends javax.swing.JInternalFrame { openString(text, name + "." + ext, false); } - private void saveFile(String content, String path) - throws IOException { - try (PrintStream out = new PrintStream(new FileOutputStream(path))) { - out.print(content); - } - setTitle("Editor - " + (new File(path)).getName()); - lastSaved = content; - isSaved = true; - MainGUI.addRecentFile(path); - } - @Override public void doDefaultCloseAction() { - if (lastSaved.equals(codeBox.getText())) { + if (lastSaved.equals(FileUtils.MD5(codeBox.getText()))) { dispose(); } else { int p = JOptionPane.showInternalConfirmDialog(this, @@ -708,11 +695,6 @@ public class CodeEditor extends javax.swing.JInternalFrame { } } - private static String readFile(String path, Charset encoding) - throws IOException { - byte[] encoded = Files.readAllBytes(Paths.get(path)); - return new String(encoded, encoding); - } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton clearBtn; diff --git a/src/net/apocalypselabs/symat/FileUtils.java b/src/net/apocalypselabs/symat/FileUtils.java new file mode 100644 index 0000000..5429e3e --- /dev/null +++ b/src/net/apocalypselabs/symat/FileUtils.java @@ -0,0 +1,116 @@ +/* + * Apocalypse Laboratories + * Open Source License + * + * Source code can be used for any purpose, as long as: + * - Compiled binaries are rebranded and trademarks are not + * visible by the end user at any time, except to give + * credit to Apocalypse Laboratories, such as by showing + * "Based on by Apocalypse Laboratories" or a + * similar notice; + * - You do not use the code for evil; + * - Rebranded compiled applications have significant + * differences in functionality; + * - and you provide your modified source code for download, + * under the terms of the GNU LGPL v3 or a comparable + * license. + * + * Compiled binaries cannot be redistributed or mirrored, + * unless: + * - You have written permission from Apocalypse Laboratories; + * - Downloads are not available from Apocalypse Laboratories, + * not even behind a paywall or other blocking mechanism; + * - or you have received a multi-computer license, in which + * case you should take measures to prevent unauthorized + * downloads, such as preventing download access from the + * Internet. + */ +package net.apocalypselabs.symat; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import javax.swing.JFileChooser; +import javax.swing.filechooser.FileNameExtensionFilter; + +/** + * File Utilities. + * + * @author Skylar + */ +public class FileUtils { + + /** + * Read a UTF-8 text file. + * + * @param path Where is the file? + * @return The file contents. + * @throws IOException + */ + public static String readFile(String path) + throws IOException { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, StandardCharsets.UTF_8); + } + + /** + * Returns the selected file from a JFileChooser, including the extension + * from the file filter. + * + * Credit to http://stackoverflow.com/users/964243/boann + * + * @param c The JFileChooser to extract from. + * @return duh. + */ + public static File getFileWithExtension(JFileChooser c) { + File file = c.getSelectedFile(); + if (c.getFileFilter() instanceof FileNameExtensionFilter) { + String[] exts = ((FileNameExtensionFilter) c.getFileFilter()).getExtensions(); + String nameLower = file.getName().toLowerCase(); + for (String ext : exts) { // check if it already has a valid extension + if (nameLower.endsWith('.' + ext.toLowerCase())) { + return file; // if yes, return as-is + } + } + // if not, append the first extension from the selected filter + file = new File(file.toString() + '.' + exts[0]); + } + return file; + } + + public static void saveFile(String content, String path, boolean addToRecent) + throws IOException { + try (PrintStream out = new PrintStream(new FileOutputStream(path))) { + out.print(content); + } + if (addToRecent) { + MainGUI.addRecentFile((new File(path)).getAbsolutePath()); + } + } + + /** + * Get an MD5 hash. + * + * http://stackoverflow.com/a/6565597/2534036 + * @param md5 the text to hash. + * @return + */ + public static String MD5(String md5) { + try { + java.security.MessageDigest md = + java.security.MessageDigest.getInstance("MD5"); + byte[] array = md.digest(md5.getBytes()); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < array.length; ++i) { + sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3)); + } + return sb.toString(); + } catch (java.security.NoSuchAlgorithmException e) { + } + return null; + } +} diff --git a/src/net/apocalypselabs/symat/Interpreter.form b/src/net/apocalypselabs/symat/Interpreter.form index 9a65362..edfe3bb 100644 --- a/src/net/apocalypselabs/symat/Interpreter.form +++ b/src/net/apocalypselabs/symat/Interpreter.form @@ -6,6 +6,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/net/apocalypselabs/symat/Interpreter.java b/src/net/apocalypselabs/symat/Interpreter.java index 1266027..8dcd83f 100644 --- a/src/net/apocalypselabs/symat/Interpreter.java +++ b/src/net/apocalypselabs/symat/Interpreter.java @@ -30,8 +30,14 @@ package net.apocalypselabs.symat; import java.awt.Color; import java.awt.Font; import java.awt.event.KeyEvent; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.text.DefaultCaret; import org.fife.ui.autocomplete.AutoCompletion; import org.fife.ui.autocomplete.CompletionProvider; @@ -44,10 +50,11 @@ public class Interpreter extends javax.swing.JInternalFrame { private final CodeRunner cr; private String[] history = new String[10]; // Command history buffer + private String commandsForExport = ""; // History for saving private int historyIndex = 0; // For going back in time and keeping things straight private String lang = "javascript"; private Object ans = 0; - + private CompletionProvider jscomp = new CodeCompleter("js").getProvider(); private CompletionProvider pycomp = new CodeCompleter("py").getProvider(); private AutoCompletion jsac = new AutoCompletion(jscomp); @@ -115,6 +122,10 @@ public class Interpreter extends javax.swing.JInternalFrame { runBtn = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); + jMenu3 = new javax.swing.JMenu(); + exportHistoryBtn = new javax.swing.JMenuItem(); + jMenu4 = new javax.swing.JMenu(); + jMenuItem1 = new javax.swing.JMenuItem(); langMenu = new javax.swing.JMenu(); jMenu1 = new javax.swing.JMenu(); javascriptMenu = new javax.swing.JRadioButtonMenuItem(); @@ -181,6 +192,26 @@ public class Interpreter extends javax.swing.JInternalFrame { jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText(">>"); + jMenu3.setText("File"); + + exportHistoryBtn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); + exportHistoryBtn.setText("Save history..."); + exportHistoryBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exportHistoryBtnActionPerformed(evt); + } + }); + jMenu3.add(exportHistoryBtn); + + jMenuBar1.add(jMenu3); + + jMenu4.setText("Edit"); + + jMenuItem1.setText("Clear window"); + jMenu4.add(jMenuItem1); + + jMenuBar1.add(jMenu4); + langMenu.setText("Language"); jMenu1.setText("Switch"); @@ -359,8 +390,34 @@ public class Interpreter extends javax.swing.JInternalFrame { } }//GEN-LAST:event_fontBtnActionPerformed + private void exportHistoryBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportHistoryBtnActionPerformed + JFileChooser fc = new JFileChooser(); + FileFilter filter; + if (javascriptMenu.isSelected()) { + filter = new FileNameExtensionFilter("SyMAT JavaScript (.syjs)", "syjs"); + } else { + filter = new FileNameExtensionFilter("SyMAT Python (.sypy)", "sypy"); + } + fc.setFileFilter(filter); + fc.addChoosableFileFilter(filter); + int result = fc.showSaveDialog(this); + if (result == JFileChooser.APPROVE_OPTION) { + try { + FileUtils.saveFile(commandsForExport, + FileUtils.getFileWithExtension(fc).toString(), + false); + } catch (IOException ex) { + JOptionPane.showInternalMessageDialog(this, + "Error saving: "+ex.getMessage(), + "Error", + JOptionPane.ERROR_MESSAGE); + } + } + }//GEN-LAST:event_exportHistoryBtnActionPerformed + private void doRunCode() { String code = inputBox.getText(); + commandsForExport += code + "\n"; mainBox.append(" " + code + "\n"); new EvalThread(code).start(); } @@ -449,12 +506,16 @@ public class Interpreter extends javax.swing.JInternalFrame { } // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JMenuItem exportHistoryBtn; private javax.swing.JMenuItem fontBtn; private javax.swing.JTextField inputBox; private javax.swing.JLabel jLabel1; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; + private javax.swing.JMenu jMenu3; + private javax.swing.JMenu jMenu4; private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JMenuItem jMenuItem1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JRadioButtonMenuItem javascriptMenu; private javax.swing.ButtonGroup langGroup; diff --git a/src/net/apocalypselabs/symat/MainGUI.form b/src/net/apocalypselabs/symat/MainGUI.form index 476876d..8a47735 100644 --- a/src/net/apocalypselabs/symat/MainGUI.form +++ b/src/net/apocalypselabs/symat/MainGUI.form @@ -343,7 +343,7 @@ - + @@ -403,8 +403,8 @@ - - + + diff --git a/src/net/apocalypselabs/symat/MainGUI.java b/src/net/apocalypselabs/symat/MainGUI.java index 28272af..a0739ee 100644 --- a/src/net/apocalypselabs/symat/MainGUI.java +++ b/src/net/apocalypselabs/symat/MainGUI.java @@ -181,11 +181,14 @@ public class MainGUI extends javax.swing.JFrame { neededLength++; } } + if (neededLength > 10) { + neededLength = 10; + } KeyValListItem[] items = new KeyValListItem[neededLength]; int i = 0; for (String f : fileList) { File file = new File(f); - if (file.isFile()) { + if (file.isFile() && i < neededLength) { items[i] = new KeyValListItem(file.getName(), file.getPath()); i++; } @@ -202,6 +205,7 @@ public class MainGUI extends javax.swing.JFrame { } public static void addRecentFile(String file) { + file = (new File(file)).getAbsolutePath(); String files = PrefStorage.getSetting("recentfiles"); String[] fileList = files.split("\n"); for (int i = 0; i < fileList.length; i++) { @@ -500,8 +504,8 @@ public class MainGUI extends javax.swing.JFrame { recentItemsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(recentItemsPanelLayout.createSequentialGroup() .addComponent(recentItemsTitle) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(recentFileBtn) .addContainerGap()) @@ -523,7 +527,7 @@ public class MainGUI extends javax.swing.JFrame { .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPaneLayout.createSequentialGroup() .addContainerGap() .addComponent(recentItemsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 184, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 145, Short.MAX_VALUE) .addComponent(jLabel2) .addContainerGap()) ); @@ -599,6 +603,7 @@ public class MainGUI extends javax.swing.JFrame { return; } CodeEditor edit = new CodeEditor(); + Debug.println(file.getValue()); edit.openFileFromName(file.getValue()); loadFrame(edit); }//GEN-LAST:event_recentFileBtnActionPerformed diff --git a/src/net/apocalypselabs/symat/SplashScreen.form b/src/net/apocalypselabs/symat/SplashScreen.form index 1bc3cb5..5836cb1 100644 --- a/src/net/apocalypselabs/symat/SplashScreen.form +++ b/src/net/apocalypselabs/symat/SplashScreen.form @@ -7,12 +7,15 @@ - + - + + + + @@ -32,48 +35,31 @@ - + - - - - - - - - - - - - - - - - + + - + - - + + - - - - - - - - - - - - + + + + + + + + + diff --git a/src/net/apocalypselabs/symat/SplashScreen.java b/src/net/apocalypselabs/symat/SplashScreen.java index b1969db..02cb380 100644 --- a/src/net/apocalypselabs/symat/SplashScreen.java +++ b/src/net/apocalypselabs/symat/SplashScreen.java @@ -27,23 +27,15 @@ */ package net.apocalypselabs.symat; -import java.awt.Color; -import java.awt.Graphics2D; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import javax.swing.ImageIcon; -import javax.swing.JProgressBar; -import javax.swing.Painter; import javax.swing.SwingUtilities; -import javax.swing.UIDefaults; -import javax.swing.UIManager; -import javax.swing.plaf.ColorUIResource; import static net.apocalypselabs.symat.MainGUI.API_URL; import static net.apocalypselabs.symat.MainGUI.APP_CODE; import static net.apocalypselabs.symat.MainGUI.VERSION_NAME; -import static net.apocalypselabs.symat.MainGUI.loadFrame; /** * @@ -56,36 +48,12 @@ public class SplashScreen extends javax.swing.JFrame { */ public SplashScreen() { initComponents(); - UIDefaults defaults = new UIDefaults(); - defaults.put("ProgressBar[Enabled].backgroundPainter", new ProgressPainter(false)); - defaults.put("ProgressBar[Enabled].foregroundPainter", new ProgressPainter(true)); - progBar.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE); - progBar.putClientProperty("Nimbus.Overrides", defaults); setIconImage((new ImageIcon( getClass().getResource("icon.png"))).getImage()); setLocationRelativeTo(null); } - class ProgressPainter implements Painter { - - private final Color color; - - public ProgressPainter(boolean foreground) { - if (foreground) { - this.color = new Color(86, 161, 243); - } else { - this.color = new Color(59, 127, 243); - } - } - - @Override - public void paint(Graphics2D gd, JProgressBar t, int width, int height) { - gd.setColor(color); - gd.fillRect(0, 0, width, height); - } - } - /** * 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 @@ -95,43 +63,30 @@ public class SplashScreen extends javax.swing.JFrame { // //GEN-BEGIN:initComponents private void initComponents() { - progBar = new javax.swing.JProgressBar(); - jLabel5 = new javax.swing.JLabel(); + dispLabel = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle(MainGUI.APP_NAME); - setMaximumSize(new java.awt.Dimension(204, 260)); - setMinimumSize(new java.awt.Dimension(204, 260)); + setMaximumSize(new java.awt.Dimension(400, 320)); + setMinimumSize(new java.awt.Dimension(400, 320)); setUndecorated(true); + setPreferredSize(new java.awt.Dimension(400, 320)); setResizable(false); addComponentListener(new java.awt.event.ComponentAdapter() { public void componentShown(java.awt.event.ComponentEvent evt) { formComponentShown(evt); } }); + getContentPane().setLayout(null); - progBar.setMaximumSize(new java.awt.Dimension(32767, 20)); - progBar.setMinimumSize(new java.awt.Dimension(10, 20)); - progBar.setPreferredSize(new java.awt.Dimension(146, 20)); - progBar.setString(""); - progBar.setStringPainted(true); - - jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/splash.gif"))); // NOI18N - - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(progBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel5) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jLabel5) - .addGap(0, 0, 0) - .addComponent(progBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - ); + dispLabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N + dispLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + dispLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/splash.gif"))); // NOI18N + dispLabel.setText("

   "); + dispLabel.setToolTipText(""); + dispLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + getContentPane().add(dispLabel); + dispLabel.setBounds(0, 0, 400, 320); pack(); }//
//GEN-END:initComponents @@ -147,11 +102,11 @@ public class SplashScreen extends javax.swing.JFrame { @Override public void run() { - setProgress(10, "Starting up..."); + setProgress("Starting up..."); if (!MainGUI.skipPython) { // Python laggggsss when used for first time, this fixes the wait later. System.out.println("Warming up Python engine, to skip run with argument 'skippython'"); - setProgress(15, "Initializing code engine..."); + setProgress("Initializing code engine..."); try { CodeRunner python = new CodeRunner(true); } catch (Exception ex) { @@ -161,17 +116,17 @@ public class SplashScreen extends javax.swing.JFrame { if (!MainGUI.skipEditor) { System.out.println("Preparing editor, to skip run with argument 'skipeditor'"); - setProgress(60, "Preparing editor..."); + setProgress("Preparing editor..."); // Get editor going too CodeEditor edit = new CodeEditor(); } - setProgress(75, "Checking for updates..."); + setProgress("Checking for updates..."); checkUpdates(); - setProgress(85, "Loading main interface..."); + setProgress("Loading main interface..."); new MainGUI().setVisible(true); - setProgress(100, "Done!"); + setProgress("Done!"); dispose(); } @@ -208,26 +163,20 @@ public class SplashScreen extends javax.swing.JFrame { } /** - * Set the progress bar. - * - * @param progress how full to make it (0 <= progress <= 100) + * Set the progress text. * @param label The String to put on the label. */ - private void setProgress(int progress, String label) { - final int prog = progress; + private void setProgress(String label) { final String lbl = label; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - progBar.setIndeterminate(false); - progBar.setValue(prog); - progBar.setString(lbl); + dispLabel.setText("

   "+lbl); } }); } } // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JLabel jLabel5; - private javax.swing.JProgressBar progBar; + private javax.swing.JLabel dispLabel; // End of variables declaration//GEN-END:variables }