private void checkForUpdate() {
		URL url = null;
		BufferedReader in = null;
		String line = null;
		try {
			
			log.trace("Checking for latest version");
			
			url = new URL(latestVersionUrl);
			in = new BufferedReader( new InputStreamReader( (InputStream)url.getContent() ) );
			int latestVersion = Integer.parseInt( in.readLine() );
			in.close();
			
			if ( latestVersion > version ) {
				
				log.trace("New version available");
				
				final String historyHtml = getVersionHistoryHtml( latestVersionTemplate, version );

				final Runnable newCallback = new Runnable() {
					@Override
					public void run() {
						log.trace("Updates button clicked (new version)");
						JDialog updatesDialog = createHtmlDialog( "Update Available", historyHtml );
						updatesDialog.setVisible(true);
					}
				};
				// Make changes from the GUI thread.
				Runnable r = new Runnable() {
					@Override
					public void run() {
						updatesCallback = newCallback;
						for ( JButton updatesButton : updatesButtonList ) {
							updatesButton.setBackground( new Color( 0xff, 0xaa, 0xaa ) );
							updatesButton.setIcon(updateIcon);
							updatesButton.setEnabled(true);
						}
						setStatusText( "A new version has been released." );
					}
				};
				SwingUtilities.invokeLater(r);
				
			} else {
				
				log.trace("Already up-to-date");

				final String historyHtml = getVersionHistoryHtml( releaseNotesTemplate, 0 );
				
				// Replacement behavior for the updates button.
				final Runnable newCallback = new Runnable() {
					@Override
					public void run() {
						log.trace("Updates button clicked (release notes)");
						JDialog updatesDialog = createHtmlDialog( "Release Notes", historyHtml );
						updatesDialog.setVisible(true);
					}
				};
				// Make changes from the GUI thread.
				Runnable r = new Runnable() {
					@Override
					public void run() {
						updatesCallback = newCallback;
						Color defaultColor = UIManager.getColor("Button.background");
						for ( JButton updatesButton : updatesButtonList ) {
							if ( defaultColor != null )
								updatesButton.setBackground(defaultColor);
							updatesButton.setIcon(releaseNotesIcon);
							updatesButton.setEnabled(true);
						}
						setStatusText( "No new updates." );
					}
				};
				SwingUtilities.invokeLater(r);
			}
			
		} catch (Exception e) {
			log.error( "Error checking for latest version", e );
			showErrorDialog( "Error checking for latest version.\n(Use the About window to check the download page manually)\n"+ e );

		} finally {
			try {if (in != null) in.close();}
			catch (IOException e) {}
		}
		
	}