Components and event handling


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Components and event handling

  1. #1
    Join Date
    Jun 2003
    Posts
    1

    Question Components and event handling

    Hi!

    I need help to develop an applet that represents a cash register. Amounts of money can be entered into a text field and are automatically added to the running total. As each amount of money is entered,the running total is updated and displayed. Abutton allows the sum to be cleared (or made Zero).

    Please help me .
    Mellisa

  2. #2
    Join Date
    Nov 2002
    Posts
    138
    you need help on everything?

  3. #3
    Join Date
    Jun 2003
    Posts
    8
    Here is a start to help you a little. I assume that you already know a bid of Java

    TextField texty = new TextField;
    Button reset, add;
    String s;
    Int i;

    //between this amd the next is the init and stuff...

    //The stuff you need to use in the add button handler

    s = texty.getText();
    i = i + Integer.parseInt( s ); //don't know if this works...I actually never tried, If it doesn't use another int and add it with int i.
    repaint();

    //in the reset button handler

    texty.setText = "";
    i = 0;
    repaint();

    //the paint methode ...don't use it in the handler

    public void paint( Graphics g) {

    g.drawString("The amount is" + i );
    }


    This is one of the many ways to do it...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center