-
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
-
you need help on everything?
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks