Ciao a tutti ho qui un codice che ho scritto che dovrebbe visualizzare l'ora internet.
in locale funziona i remoto no perché?
il sito è qui
import java.util.*;
import java.awt.*;
import java.awt.Color.*;
import java.awt.event.*;
import java.applet.*;
class internetTime extends Applet {
public void init() {
Color oro = new Color(204,204,136);
Color back = new Color(6,33,61);
ora orol;
this.setBackground(back);
clock = new Label("Time: @ 000");
orol = new ora(clock);
orol.start();
clock.setForeground(oro);
clock.setFont(new Font("Verdana", Font.BOLD, 11));
add(clock);
}
private Color back, oro, colfont, color;
private Label clock, autore;
}
class ora extends Thread {
ora(Label l){
this.clo = l;
}
public void run(){
amRunning = true;
while(true){
if (amRunning){
GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
int h = ((gc.get(Calendar.HOUR_OF_DAY))+1)*60;
if (h >= 1440){ h= 0;}
int m = (gc.get(Calendar.MINUTE));
int inter = (((h+m)*1000)/1440);
clo.setText("Time: @"+inter);
try
{this.sleep(20);} catch (Exception e){;}
}
}
}
private Label l, clo;
private boolean amRunning;
private int h, m, inter;
}