Results 1 to 2 of 2

Thread: java problem

  1. #1
    casey is offline Member
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Default java problem

    i want to display a message input by a user on an applet
    Java Code:
    /**
    * @(#)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 );
    
    }
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default

    You don't want to do your reading in your paint method like that.

    Instead, ask for input from the start method. Also, are you sure you have access to System.in from an Applet? And is there a reason you're using an Applet instead of a JApplet?

    PS- In the future, you might want to use a more meaningful post title. Posts with titles like "java problem" tend to be ignored.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Need Help!:( Java problem
    By ra21 in forum New To Java
    Replies: 2
    Last Post: 02-01-2011, 11:41 PM
  2. Problem Display Jmenubar Java Se6 u23 versus Java SE6 u22
    By Ravanelly in forum Advanced Java
    Replies: 0
    Last Post: 01-07-2011, 10:36 AM
  3. Java Problem. Need Help!
    By bob101 in forum New To Java
    Replies: 6
    Last Post: 03-19-2009, 05:34 AM
  4. Help, java problem
    By Suriman in forum New To Java
    Replies: 4
    Last Post: 03-09-2009, 05:26 PM
  5. Problem in java
    By saytri in forum New To Java
    Replies: 4
    Last Post: 01-16-2008, 11:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •