I have a GUI clock in Java (intelliJ 14) that uses a simple timer to update, when I run the program from IntelliJ the timer and clock work fine. However, when I export the project as an executable .jar file, and run it, the timer doesn't run at all, causing the clock to freeze.
Code for the clock:
private static final JLabel Clock = new JLabel("");
protected static final DateFormat CLOCK_FORMAT = new SimpleDateFormat("hh:mm:ss a");
Clock.setBounds(482, 360, 135, 35);
contentPane.add(Clock);
Clock.setFont(new Font("DS-Digital", Font.PLAIN, 27));
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateClock();
}
});
timer.start();
updateClock():
protected void updateClock() {
Clock.setText(CLOCK_FORMAT.format(System.currentTimeMillis()));
}
Whenever I run this from IntelliJ it works perfectly fine, but if I export it as a .jar the timer is never called. Any help would be great, thanks in advance!