Added preparation for online version check

This commit is contained in:
mmk2410 2015-06-01 23:34:04 +02:00
parent 0cd8b05940
commit e2a90823b7
2 changed files with 28 additions and 4 deletions

View File

@ -78,7 +78,9 @@
<children>
<component id="b5dfc" class="javax.swing.JTextArea" binding="inputAreaNormalMorse">
<constraints/>
<properties/>
<properties>
<text value="Enter your text"/>
</properties>
</component>
</children>
</scrollpane>

View File

@ -31,12 +31,16 @@ import de.marcelkapfer.c.morseconverter.intelligentCodeRecognization.WrittenMors
import javax.swing.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Created by mmk on 5/31/15.
*/
public class Main extends JFrame {
// Version numbers for update check
public static final int actualVersion = 200;
public int latestVersion = actualVersion;
public JTabbedPane morseConverterPane;
private JPanel panel1;
private JTextArea inputAreaWrittenMorse;
@ -60,6 +64,24 @@ public class Main extends JFrame {
instantNormalMorseConvert();
}
});
// Trying to read a file from a server
try {
URL versionURL = new URL("http://c2/LAB/java/morseconverter/version.txt");
BufferedReader versionReader = new BufferedReader(new InputStreamReader(versionURL.openStream()));
latestVersion = Integer.valueOf(versionReader.readLine());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//TODO To be also shown in the about view
if (actualVersion < latestVersion){
JOptionPane.showMessageDialog(null, "An Update is available!");
}
}
// The holy main method