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> <children>
<component id="b5dfc" class="javax.swing.JTextArea" binding="inputAreaNormalMorse"> <component id="b5dfc" class="javax.swing.JTextArea" binding="inputAreaNormalMorse">
<constraints/> <constraints/>
<properties/> <properties>
<text value="Enter your text"/>
</properties>
</component> </component>
</children> </children>
</scrollpane> </scrollpane>

View file

@ -31,12 +31,16 @@ import de.marcelkapfer.c.morseconverter.intelligentCodeRecognization.WrittenMors
import javax.swing.*; import javax.swing.*;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; 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 { public class Main extends JFrame {
// Version numbers for update check
public static final int actualVersion = 200;
public int latestVersion = actualVersion;
public JTabbedPane morseConverterPane; public JTabbedPane morseConverterPane;
private JPanel panel1; private JPanel panel1;
private JTextArea inputAreaWrittenMorse; private JTextArea inputAreaWrittenMorse;
@ -60,6 +64,24 @@ public class Main extends JFrame {
instantNormalMorseConvert(); 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 // The holy main method