hej.. nu har jeg forsøgt mig en del.
når jeg ser min applet, og en ven kommer ind i min applet, så får jeg intet udskrevet, hvorfor?
En der kan fortælle mig hvad jeg gør forkert?
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.net.Socket;
import java.net.UnknownHostException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.net.*;
import java.io.BufferedOutputStream.*;
public class z extends Applet implements MouseListener
{
Socket sock = null;
Image figur;
Image offScreen;
Graphics bufferGfx;
Image baggrund;
Point mouseDown = null;
String brugernavn;
public void send(String data) {
try {
Socket sock = new Socket("localhost", 9999);
BufferedOutputStream output = new BufferedOutputStream(sock.getOutputStream());
output.write((data).getBytes());
output.flush();
}catch (IOException ioe){
ioe.printStackTrace();
}
}
public void init()
{
//System.out.println("Her skulle den uskrive init!");
brugernavn = getParameter("brugernavn");
addMouseListener(this);
figur = getImage(getCodeBase(),"normal.gif");
baggrund = getImage(getCodeBase(),"reception.jpg");
offScreen = createImage (this.getWidth(), this.getHeight());
bufferGfx = offScreen.getGraphics();
try {
sock = new Socket("localhost",9999);
PrintWriter out = new PrintWriter(sock.getOutputStream(),true);
out.println("UDSKRIVER DETTE");
BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
String userInput;
while ((userInput = stdIn.readLine()) != null)
{
out.println(userInput);
System.out.println("MODTOG: " + in.readLine());
}
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void paint(Graphics g)
{
bufferGfx.setColor(Color.WHITE);
bufferGfx.clearRect(0,0,this.getWidth(),this.getHeight());
bufferGfx.drawImage(baggrund,0,0,this);
if (mouseDown != null)
bufferGfx.drawImage(figur, mouseDown.x-20, mouseDown.y-15, this);
bufferGfx.drawString(brugernavn,mouseDown.x-20,mouseDown.y+65);
g.drawImage(offScreen,0,0,this);
}
public void mouseClicked(MouseEvent e)
{
mouseDown = new Point((int) e.getX(), (int) e.getY());
repaint();
}
public void mousePressed(MouseEvent e) {
mouseDown = new Point((int) e.getX(), (int) e.getY());
repaint();
}
public void update (Graphics g)
{
paint(g);
}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
}
for jeg bruger jo out.println("UDSKRIV"); men den viser intet i console.