Fejl ved compile til .class
Hejsa, en der vil compile denne kode, da mit compile program er blevet slettet?---->
package tisdk;
import java.applet.Applet;
import java.awt.*;
import java.io.IOException;
import java.io.PrintStream;
import java.net.*;
import java.util.*;
public class test extends Applet
implements Runnable
{
public test()
{
guid = "";
properties = new Properties();
clothes = "0";
face = "0";
hair = "0";
sex = 1;
color = 0;
hairIdx = 0;
clothesIdx = 0;
faceIdx = 0;
availableClothes = "0";
availableFace = "0";
availableHair = "0";
reverse = false;
run = true;
thisThread = new Thread(this);
}
public void init()
{
guid = getParameter("GUID");
try
{
URLConnection urlCon = null;
URL url = new URL(getCodeBase().toString() + "http://hhsrv.n.dk/ClothesSelector/clothesselector.ini");
urlCon = url.openConnection();
properties.load(urlCon.getInputStream());
}
catch(MalformedURLException mue)
{
mue.printStackTrace();
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
sex = Integer.parseInt(getParameter("sex"));
color = Integer.parseInt(getParameter("color"));
container = new GraphicsContainer(this, sex, color);
clothes = getParameter("clothes");
face = getParameter("face");
hair = getParameter("hair");
availableClothes = getParameter("availableClothes");
availableFace = getParameter("availableFace");
availableHair = getParameter("availableHair");
containerThread = new Thread(container);
queueImages();
}
public void queueImages()
{
String job;
for(StringTokenizer hairTokens = new StringTokenizer(availableHair, "|"); hairTokens.hasMoreTokens(); container.queueHair(job))
job = hairTokens.nextToken();
String job;
for(StringTokenizer faceTokens = new StringTokenizer(availableFace, "|"); faceTokens.hasMoreTokens(); container.queueFace(job))
job = faceTokens.nextToken();
String job;
for(StringTokenizer clothesTokens = new StringTokenizer(availableClothes, "|"); clothesTokens.hasMoreTokens(); container.queueClothes(job))
job = clothesTokens.nextToken();
container.getClass();
container.queueCustom(container.imagePath + "root.gif");
container.queueCustom("http://hhsrv.n.dk/ClothesSelector/background.gif");
thisThread.start();
containerThread.start();
}
public void run()
{
do
{
repaint();
try
{
Thread.sleep(500L);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
} while(true);
}
public Color getColor(String colorname)
{
StringTokenizer tokenizer = new StringTokenizer(properties.getProperty(colorname, "0 0 0"));
int r = Integer.parseInt(tokenizer.nextToken());
int g = Integer.parseInt(tokenizer.nextToken());
int b = Integer.parseInt(tokenizer.nextToken());
return new Color(r, g, b);
}
public void locateLayout()
{
for(int i = 0; i < container.hairJobs.size(); i++)
{
String img = (String)container.hairJobs.elementAt(i);
if(!img.equals(hair))
continue;
hairIdx = i;
break;
}
for(int i = 0; i < container.faceJobs.size(); i++)
{
String img = (String)container.faceJobs.elementAt(i);
if(!img.equals(face))
continue;
faceIdx = i;
break;
}
for(int i = 0; i < container.clothesJobs.size(); i++)
{
String img = (String)container.clothesJobs.elementAt(i);
if(!img.equals(clothes))
continue;
clothesIdx = i;
break;
}
}
public void paintPreload(Graphics g)
{
g.setColor(getColor("backgroundColor"));
g.fillRect(0, 0, getBounds().width, getBounds().height);
g.setColor(getColor("textColor"));
FontMetrics metrics = g.getFontMetrics();
String text = "Indl\346ser lortet: ";
int x = getBounds().width / 2 - metrics.stringWidth(text);
int y = getBounds().height / 2;
g.drawString(text + (container.preloadedPercentage() <= 100 ? container.preloadedPercentage() : 100) + "%", x, y);
x = 3;
int progressHeight = 15;
y += progressHeight / 2;
int progressBorder = 1;
int progressWidth = getBounds().width - x * 2;
g.setColor(getColor("progressBorderColor"));
g.fillRect(x, y, progressWidth, progressHeight);
g.setColor(getColor("progressBackgroundColor"));
g.fillRect(x + progressBorder, y + progressBorder, progressWidth - progressBorder * 2, progressHeight - progressBorder * 2);
double value = (double)container.preloadedPercentage() / 100D;
double progressWidthPercentage = (int)((double)progressWidth * value);
int pers = (int)progressWidthPercentage;
g.setColor(getColor("progressBarColor"));
g.fillRect(x + progressBorder, y + progressBorder, pers - progressBorder * 2, progressHeight - progressBorder * 2);
}
public void paintMain(Graphics g)
{
int width = getBounds().width;
int height = getBounds().height;
g.setColor(getColor("backgroundColor"));
g.fillRect(0, 0, width, height);
Image bg = getImage(getCodeBase(), "http://hhsrv.n.dk/ClothesSelector/background.gif");
g.drawImage(bg, 0, 0, this);
container.getClass();
rootImg = getImage(getCodeBase(), container.imagePath + "root.gif");
g.drawImage(rootImg, width / 2 - rootImg.getWidth(this) / 2, (height - rootImg.getHeight(this)) / 2, this);
int imagesBaseline = (height - rootImg.getHeight(this)) / 2 + rootImg.getHeight(this);
paintClothes(g);
if(reverse)
{
paintFace(g);
paintHair(g);
} else
{
paintHair(g);
paintFace(g);
}
}
public void paintHair(Graphics buffer)
{
int width = getBounds().width;
int height = getBounds().height;
int imagesBaseline = (height - rootImg.getHeight(this)) / 2 + rootImg.getHeight(this);
if(hairIdx > 0)
{
Image prevHairImg = container.hair[hairIdx - 1];
buffer.drawImage(prevHairImg, 10, 10, this);
}
Image hairImg = container.hair[hairIdx];
if(hairImg != null)
buffer.drawImage(hairImg, width / 2 - hairImg.getWidth(this) / 2, imagesBaseline - hairImg.getHeight(this), this);
if(hairIdx < container.hair.length - 1)
{
Image nextHairImg = container.hair[hairIdx + 1];
buffer.drawImage(nextHairImg, width - 10 - nextHairImg.getWidth(this), 10, this);
}
}
public void paintFace(Graphics buffer)
{
int width = getBounds().width;
int height = getBounds().height;
int imagesBaseline = (height - rootImg.getHeight(this)) / 2 + rootImg.getHeight(this);
if(faceIdx > 0)
{
Image prevFaceImg = container.face[faceIdx - 1];
buffer.drawImage(prevFaceImg, 10, (height - prevFaceImg.getHeight(this)) / 2, this);
}
Image faceImg = container.face[faceIdx];
if(faceImg != null)
buffer.drawImage(faceImg, width / 2 - faceImg.getWidth(this) / 2, imagesBaseline - faceImg.getHeight(this), this);
if(faceIdx < container.face.length - 1)
{
Image nextFaceImg = container.face[faceIdx + 1];
buffer.drawImage(nextFaceImg, width - 10 - nextFaceImg.getWidth(this), (height - nextFaceImg.getHeight(this)) / 2, this);
}
}
public void paintClothes(Graphics buffer)
{
int width = getBounds().width;
int height = getBounds().height;
int imagesBaseline = (height - rootImg.getHeight(this)) / 2 + rootImg.getHeight(this);
if(clothesIdx > 0)
{
Image prevClothesImg = container.clothes[clothesIdx - 1];
buffer.drawImage(prevClothesImg, 10, height - 10 - prevClothesImg.getHeight(this), this);
}
Image clothesImg = container.clothes[clothesIdx];
if(clothesImg != null)
buffer.drawImage(clothesImg, width / 2 - clothesImg.getWidth(this) / 2, imagesBaseline - clothesImg.getHeight(this), this);
if(clothesIdx < container.clothes.length - 1)
{
Image nextClothesImg = container.clothes[clothesIdx + 1];
buffer.drawImage(nextClothesImg, width - 10 - nextClothesImg.getWidth(this), height - 10 - nextClothesImg.getHeight(this), this);
}
}
public void prevHair()
{
if(hairIdx > 0)
hairIdx--;
repaint();
}
public void nextHair()
{
if(hairIdx < container.hair.length - 1)
hairIdx++;
repaint();
}
public void prevFace()
{
if(faceIdx > 0)
faceIdx--;
repaint();
}
public void nextFace()
{
if(faceIdx < container.face.length - 1)
faceIdx++;
repaint();
}
public void prevClothes()
{
if(clothesIdx > 0)
clothesIdx--;
repaint();
}
public void nextClothes()
{
if(clothesIdx < container.clothes.length - 1)
clothesIdx++;
repaint();
}
public void reverse()
{
reverse = !reverse;
repaint();
}
public void submit()
{
try
{
String _hair = (String)container.hairJobs.elementAt(hairIdx);
String _face = (String)container.faceJobs.elementAt(faceIdx);
String _clothes = (String)container.clothesJobs.elementAt(clothesIdx);
URL url = new URL(getCodeBase(), "http://hhsrv.n.dk/ClothesSelector/saveAvatar.asp?guid=" + guid + "&hair=" + _hair + "&face=" + _face + "&clothes=" + _clothes + "&reverse=" + reverse);
url.openConnection();
url.openStream();
}
catch(MalformedURLException ignore)
{
ignore.printStackTrace();
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
System.out.println("Saved...");
}
public void update(Graphics g)
{
imageBuffer = createImage(getBounds().width, getBounds().height);
Graphics buffer = imageBuffer.getGraphics();
if(container.isPreloaded)
paintMain(buffer);
else
paintPreload(buffer);
paint(buffer);
buffer.dispose();
g.drawImage(imageBuffer, 0, 0, null);
}
public void paint(Graphics g1)
{
}
private Image imageBuffer;
private Image rootImg;
private String guid;
public Properties properties;
public String clothes;
public String face;
public String hair;
public int sex;
public int color;
public int hairIdx;
public int clothesIdx;
public int faceIdx;
public GraphicsContainer container;
public String availableClothes;
public String availableFace;
public String availableHair;
public boolean reverse;
public boolean run;
public Thread containerThread;
public Thread thisThread;
}
