Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6926589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:56:16+00:00 2026-05-27T10:56:16+00:00

Hello I use a JApplet to show a Jpanel with an image that I

  • 0

Hello I use a JApplet to show a Jpanel with an image that I get from the network but the applet is loading and not showing the image.

Code:

package com.ntenisot;

import java.io.*;
import java.net.*;
import javax.swing.*;

import java.awt.event.*;
import java.awt.*;
import java.applet.*;

public class Cliente extends JApplet {

JTextField tf;
Lienzo lienzo;
Socket con;
ObjectOutputStream salida;
ObjectInputStream entrada;

public void init(){
    System.out.println("initializing");
    tf = new JTextField(10);
    lienzo=new Lienzo();    
    setSize(1000,1000);
    lienzo.setSize(900,900);
    lienzo.setVisible(true);
    setContentPane(lienzo);

    Container container = getContentPane();
    container.setBackground(Color.pink);
    container.setLayout(new FlowLayout());

    // Text area 1
    String string = "Some text in here, Some text in here, Some text in here";
    JTextArea textArea1 = new JTextArea(string, 10, 15);
    container.add(new JScrollPane(textArea1));
}

public void start() {
    ejecutar();
}

void ejecutar(){
    System.out.println("executing1");

    try{

        con = new Socket("127.0.0.1",5700);
        salida = new ObjectOutputStream(con.getOutputStream());
        salida.flush();
        entrada = new ObjectInputStream(con.getInputStream());
        System.out.println("executing");
        procesar();


    }
    catch(IOException e){
        System.out.println("error");
    }

}   

void procesar() throws IOException {
    System.out.println("processing");

    try{

        while(true){
            ImageIcon img = (ImageIcon) entrada.readObject();
            escribir(img);
        }
    }catch(ClassNotFoundException e){}

}

void escribir(final ImageIcon img){

    SwingUtilities.invokeLater(
            new Runnable(){
                public void run(){
                    lienzo.pinta(img);
                }

            }
            );

}

class Lienzo extends JPanel{

    ImageIcon img=null ;

    public void pinta(ImageIcon img){
        this.img=img;
        repaint();
    }

    public void paintComponent(Graphics g){

        super.paintComponent(g);

        if(img!=null)   
            img.paintIcon(this,g,10,10);

    }


}   

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:56:17+00:00Added an answer on May 27, 2026 at 10:56 am

    I did not test your code, but it seems method procesar cannot terminate. Therefore, the method init will also not terminate. I think you could remove the surrounding while (true) loop, as setting the image once is enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello im trying to use random integer range and the values that i get
Hello I have use DOMDocs in the past but I am stuck how to
hello guys i am try to use the StringUtils.remove Method but the below exception
hello I have this code that use to sort a datatable. Dim sortingIndex As
I define namespace inside a clojure lib without ', (ns myproject.hello) But, I use
hello i try to use simple application in android but i have many problems
Hello i'm trying to use autocomplete dropdownlist plugin that name is ufd. Anyway, I
Hello I use this code to remove empty input text fields from my form:
Hello is there a way to use svn command line from eclipse? Within eclipse
Hello I try to use PcapDotNet dll but I can't add reference to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.