Пишет: "AppletClo.java": cannot resolve symbol: constructor Thread (temp.AppletClo)in class java.lang.Thread at line 59, column 15
Если кто видит ошибку, подскажите...
Код | package temp;
import java.awt.*; import java.awt.event.*; import java.applet.*; import java.util.Date; import java.lang.Thread;
public class AppletClo extends Applet { private boolean isStandalone = false; Graphics g; Thread motor; Date date; Dimension d;
//Get a parameter value public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); }
//Construct the applet public AppletClo() { }
//Initialize the applet public void init() { try { g = getGraphics(); date = new Date(); Font fn = new Font("Helvetica", Font.PLAIN, 24);
setFont(fn); d = this.size(); setBackground(Color.black);
} catch (Exception e) { e.printStackTrace(); } }
//Component initialization private void jbInit() throws Exception { }
//Start the applet public void start () { if(motor == null) motor = new Thread(this); motor.start(); }
//Stop the applet public void stop () { motor.stop(); motor = null; } public void run() { motor.setPriority(Thread.MIN_PRIORITY);
while( motor != null) { date = new Date(); repaint(); try { Thread.sleep(1000); } catch (Exception e) {}; } }
public void paint(Graphics g) { g.setColor(Color.green); FontMetrics fm = g.getFontMetrics(); int hi = date.getHours(); int mi = date.getMinutes(); int si = date.getSeconds(); String s,m,h; if(si<10) s="0"+si; else s=""+si; if(mi<10) m="0"+mi; else m=""+mi; if(hi<10) h="0"+hi; else h=""+hi; String ss = h+":"+m+":"+s; int x = (d.width - fm.stringWidth(ss))/2; int y = fm.getAscent() + ( d.height - (fm.getAscent() + fm.getDescent()))/2; g.drawString(ss,x,y); }
//Destroy the applet public void destroy() { }
//Get Applet information public String getAppletInfo() { return "Applet Information"; }
//Get parameter info public String[][] getParameterInfo() { return null; } }
| |