Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Applet Dialog Box.

Options
  • 27-01-2001 6:30pm
    #1
    Closed Accounts Posts: 1,484 ✭✭✭


    Lo,

    I'm taking a little look at applets and I was wondering if someone could put up some sample code of how you put a dialog box into your applet and read information from it.

    Thanks.


Comments

  • Registered Users Posts: 1,481 ✭✭✭satchmo


    The TextField class is the one you're looking for. Look in the API under java.awt.TextField for its methods, but getText() inherited from TextComponent is probably the one you'll use most.
    int columns=20;
    TextField tf=new TextField("Default String", columns); //create a TextField object with default value and size
    String text=tf.getText(); //get the text entered into the TextField. Will return "Default String"
    

    To add it to an applet, use the Applet's add() method. Look up the add() methods in the Container class, which Applet inherits from. There's a few different ways to do it, so choose whichever one suits you best.

    You'll probably want to add some Panel or Canvas objects to the applet first, arrange them, and then add whatever components you want (like TextFields) to them.


Advertisement