如题:
------解决方案--------------------
javax.swing.JPanel p = new javax.swing.JPanel();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(p);
byte b[] = new byte[bos.size()];
b = bos.toByteArray();
System.out.println(java.util.Arrays.toString(b));
bos.close();
oos.close();