Display Image on Panel after transfered via Socket :: Java
import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io.IOException; import java.net.Socket; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JPanel; /** * * @author ipopp */ public class imageClientPanel { public static BufferedImage image; public static JPanel panel; public static void main (String[] args) { JFrame frame = new JFrame("test"); frame.setSize(800,600); frame.add(panel = new JPanel() { @Override public void paintComponent(Graphics graphics) { super.paintComponents(graphics); if(image != null) { graphics.drawImage(image, 0, 0, this); } else { graphics.setColor(Color.black); graphics.fillRect(0,0,800,600); } } }); frame.setDefaultCloseOperation