I'm writing an application launcher and I've currently got a HTML file which displays the changes to the application, this works like a charm, and everytime a new update is released I'll list the changes in the HTML file and it will automatically update in the users .exe/.jar file.
However the current method I'm using requires the user to download the .exe/.jar file for the updates to show, so how could I come across fetching the HTML file from my Webserver, and displaying it accordingly.
Here is my current code;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
public class Launcher extends JFrame {
private static final long serialVersionUID = -6224390548062243879L;
public static void createFrame() {
JEditorPane editorPane = new JEditorPane();
editorPane.setEditable(false);
java.net.URL helpURL = Launcher.class.getResource("/changelog.html");
if (helpURL != null) {
try {
editorPane.setPage(helpURL);
} catch (IOException e) {
System.err.println("Attempted to read a bad URL: " + helpURL);
}
} else {
System.err.println("Couldn't find file: changelog.html");
}
JScrollPane editorScrollPane = new JScrollPane(editorPane);
editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
editorScrollPane.setPreferredSize(new Dimension(350, 300));
editorScrollPane.setMinimumSize(new Dimension(10, 10));
JLabel emptyLabel = new JLabel("");
emptyLabel.setPreferredSize(new Dimension(300, 300));
JButton launch = new JButton("Launch!");
launch.setPreferredSize(new Dimension(350, 50));
JFrame f = new JFrame();
f.setTitle("Stonelore Launcher");
f.setSize(350, 400);
f.setLocationRelativeTo(null);
f.getContentPane().add(emptyLabel, BorderLayout.CENTER);
f.getContentPane().add(editorScrollPane, BorderLayout.NORTH);
f.getContentPane().add(launch, BorderLayout.SOUTH);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setResizable(false);
f.setVisible(true);
}
public static void main(String[] args) {
createFrame();
}
}