I want to display a message input by a user on an applet

/**

 * @(#)Hello.java
 *
 * Hello Applet application
 *
 * @author
 * @version 1.00 2011/3/17
 */

import java.awt.*;
import java.applet.*;
import java.io.Console.*;
import java.io.*;

public class Hello extends Applet {

    public void init() {
    }

    public void paint(Graphics g) {

    BufferedReader keyboard;

    String Message;
    try{

        g.drawString("Enter message to be displayed:",0,20);

         keyboard = new BufferedReader(new InputStreamReader(System.in));

          Message=keyboard.readLine();
    }
    catch(IOException e){

        g.drawString("Error reading input!",0,40);
    }

      g.drawString(Message,0,40);


        g.drawString("Hello World!!!", 50, 60 );

    }
}

please change/replace Applet with JApplet

when I replace Applet i get errors so i was thinking that you could re-write it and send it back.

you are right! your code run ok.

you can display your ide and applet in the same window. Don't min the applet window when you input .Because the applet call 'repaint()' the message is empty !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.