eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to Web Programming
Exercise Seven  
  • Ready for Homework? Your assignment is to build an interface for a calculator using buttons for each of the keys on the calculator keypad and a TextField for the display.

    [Example]

    import java.awt.*;
    
    public class Calculator extends Panel
      {
    
      public TextField displayField;
      public Panel     buttonPanel;
      public Button    oneButton, twoButton, threeButton,
    		   fourButton, fiveButton, sixButton,
    		   sevenButton, eightButton, nineButton,
    		   zeroButton, addButton, subtractButton,
     		   multiplyButton, divideButton,
    		   equalsButton;
    
      public Calculator()
        {
        setLayout(new BorderLayout());
        displayField = new TextField();
        add("North", displayField);
    
        buttonPanel = new Panel();
        buttonPanel.setLayout(new GridLayout(5,3));
    
        oneButton = new Button("1");
        twoButton = new Button("2");
        threeButton = new Button("3");
        fourButton = new Button("4");
        fiveButton = new Button("5");
        sixButton = new Button("6");
        sevenButton = new Button("7");
        eightButton = new Button("8");
        nineButton = new Button("9");
        zeroButton = new Button("0");
        addButton = new Button("+");
        subtractButton = new Button("-");
        multiplyButton = new Button("*");
        divideButton = new Button("/");
        equalsButton = new Button("=");
    
        buttonPanel.add(oneButton);
        buttonPanel.add(twoButton);
        buttonPanel.add(addButton);
        buttonPanel.add(threeButton);
        buttonPanel.add(fourButton);
        buttonPanel.add(subtractButton);
        buttonPanel.add(fiveButton);
        buttonPanel.add(sixButton);
        buttonPanel.add(multiplyButton);
        buttonPanel.add(sevenButton);
        buttonPanel.add(eightButton);
        buttonPanel.add(divideButton);
        buttonPanel.add(nineButton);
        buttonPanel.add(zeroButton);
        buttonPanel.add(equalsButton);
    
        add("Center", buttonPanel);
        }
    
      public static void main(String[] args)
        {
        Frame baseFrame = new Frame();
        Calculator c = new Calculator();
        baseFrame.add("Center", c);
        baseFrame.reshape(10,10,200,200);
        baseFrame.setTitle("Calculator Example");
        baseFrame.show();
        }
      }
    
    

Previous Page | Next Page