我怎樣才能發送對象Image
?我得到這個錯誤:如何序列化包含圖像的對象?
java.io.NotSerializableException: org.eclipse.swt.graphics.Image
我可以發送正常的對象,字符串或其他任何對象。
public void sentObject(Card GraczK) throws IOException
{
outt.writeObject(GraczK);
outt.flush();
System.out.print(GraczK);
}
卡類型
public class Card implements Serializable {
private int Value, Colour;
private Image img;
public Card(int i, int j) {
Colour = i;
Value = j;
img = new Image(null, MainWarSever.class.getResourceAsStream("/Karty/k" + Value + " (" + Colour + ").png"));
}
public int getValue() {
return Value;
}
public int getColour() {
return Colour;
}
public Image getImg() {
return img;
}
}
偉大的傢伙!謝謝! – Pekus