Multichoice1456.java, a 1456 applet landscape.

William Overington

Copyright 2000 William Overington

This document is intended for people who have a knowledge of Java and would like to learn more about how this 1456 applet landscape is programmed in Java. This section may be safely missed out by people who are reading these documents just to program in 1456 object code itself without learning about the underlying Java software that allows it to run.

Here is the source code of the Multichoice1456.java program.

import java.awt.*;
import java.awt.event.*;
 
public class Multichoice1456 extends java.applet.Applet implements
                         ActionListener,ItemListener,MouseListener

// Software written by William Overington
// WOverington@ngo.globalnet.co.uk
// 30 September 2000
//
// Software interrupt service routine sections 91 through to 95 added
// 4 October 2000
//
// Background colour of the checkboxes explicitly set to white after
// discovering that they show grey when viewed using Internet
// Explorer version 4, even though they showed white using Internet
// Explorer version 5.  Perhaps they were transparent when viewed
// using Internet Explorer 5.  An interesting point learned here.
// 5 October 2000
//
// Copyright 2000 William Overington
//
// This software is a 1456 Applet Landscape for use with
// 1456 object code.
// This software is derived from the Print1456 1456 applet landscape
// by the same author.
// A five button checkbox group is added and a button is added.
// The 1456 object code system is explained at
// http://www.users.globalnet.co.uk/~ngo

  {
    Engine1456 firefly = new Engine1456();
    String software,software01,software02,software03,software04,
           software05,software06,software07,software08,software09;
    int length,length01,length02,length03,length04,length05,length06,
               length07,length08,length09;
    int obeycode;
    char resultchar;
    String string00,string01,string02,string03,string04,
                    string05,string06,string07,string08,string09;
    String go1ButtonLabel;
    int pressx,pressy;
    boolean shiftdown,controldown,altdown;
    boolean splittheeventhandler = false;
    boolean colourtoolbarison = false;
    Font font1120, font1122, font1180, font1182,
         font1240, font1242, font1360, font1362,
         font1480, font1482, font1600, font1602,
         font1720, font1722;
    int fontcode;
    Button go1Button = new Button
                       ("Please click to register your answer.");
    CheckboxGroup radioset1 = new CheckboxGroup();
    Checkbox radio91 = new Checkbox(" ",false,  radioset1);
    Checkbox radio92 = new Checkbox(" ",false, radioset1);
    Checkbox radio93 = new Checkbox(" ",false, radioset1);
    Checkbox radio94 = new Checkbox(" ",false, radioset1);
    Checkbox radio95 = new Checkbox(" ",false, radioset1);

    public void init()
      {
        setLayout(null);
        setBounds(0,0,700,400);
        go1Button.addActionListener(this);
        go1Button.setLocation(200,305);
        go1Button.setSize(300,30);
        add(go1Button);
        radio91.addItemListener(this);
        radio91.setLocation(100,90);
        radio91.setSize(50,30);
        radio91.setBackground(Color.white);
        add(radio91);
        radio92.addItemListener(this);
        radio92.setLocation(100,130);
        radio92.setSize(50,30);
        radio92.setBackground(Color.white);
        add(radio92);
        radio93.addItemListener(this);
        radio93.setLocation(100,170);
        radio93.setSize(50,30);
        radio93.setBackground(Color.white);
        add(radio93);
        radio94.addItemListener(this);
        radio94.setLocation(100,210);
        radio94.setSize(50,30);
        radio94.setBackground(Color.white);
        add(radio94);
        radio95.addItemListener(this);
        radio95.setLocation(100,250);
        radio95.setSize(50,30);
        radio95.setBackground(Color.white);
        add(radio95);
        addMouseListener(this);

        go1ButtonLabel = getParameter("BUTTON01");
        if (go1ButtonLabel != null)
          {
            firefly.loadStringFromString(0,go1ButtonLabel);
            go1ButtonLabel=firefly.string1456Get(0);
            go1Button.setLabel(go1ButtonLabel);
          }

        software="";
        software01 = getParameter("SOFTWARE01");
        if (software01 != null)
          {
            length01=software01.length();
            if (length01 > 0)
              {
                software=software+software01;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software02 = getParameter("SOFTWARE02");
        if (software02 != null)
          {
            length02=software02.length();
            if (length02 > 0)
              {
                software=software+software02;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software03 = getParameter("SOFTWARE03");
        if (software03 != null)
          {
            length03=software03.length();
            if (length03 > 0)
              {
                software=software+software03;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }
        
        software="";
        software04 = getParameter("SOFTWARE04");
        if (software04 != null)
          {
            length04=software04.length();
            if (length04 > 0)
              {
                software=software+software04;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software05 = getParameter("SOFTWARE05");
        if (software05 != null)
          {
            length05=software05.length();
            if (length05 > 0)
              {
                software=software+software05;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software06 = getParameter("SOFTWARE06");
        if (software06 != null)
          {
            length06=software06.length();
            if (length06 > 0)
              {
                software=software+software06;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software07 = getParameter("SOFTWARE07");
        if (software07 != null)
          {
            length07=software07.length();
            if (length07 > 0)
              {
                software=software+software07;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software08 = getParameter("SOFTWARE08");
        if (software08 != null)
          {
            length08=software08.length();
            if (length08 > 0)
              {
                software=software+software08;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }

        software="";
        software09 = getParameter("SOFTWARE09");
        if (software09 != null)
          {
            length09=software09.length();
            if (length09 > 0)
              {
                software=software+software09;
                firefly.loadSoftwareFromAppletParameters(software);
              }
          }
      
        string01 = getParameter("STRING01");
        if (string01 != null)
          {
            firefly.loadStringFromString(1,string01);
          }

        string02 = getParameter("STRING02");
        if (string02 != null)
          {
            firefly.loadStringFromString(2,string02);
          }

        string03 = getParameter("STRING03");
        if (string03 != null)
          {
            firefly.loadStringFromString(3,string03);
          }

        string04 = getParameter("STRING04");
        if (string04 != null)
          {
            firefly.loadStringFromString(4,string04);
          }

        string05 = getParameter("STRING05");
        if (string05 != null)
          {
            firefly.loadStringFromString(5,string05);
          }

        string06 = getParameter("STRING06");
        if (string06 != null)
          {
            firefly.loadStringFromString(6,string06);
          }

        string07 = getParameter("STRING07");
        if (string07 != null)
          {
            firefly.loadStringFromString(7,string07);
          }

        string08 = getParameter("STRING08");
        if (string08 != null)
          {
            firefly.loadStringFromString(8,string08);
          }

        string09 = getParameter("STRING09");
        if (string09 != null)
          {
            firefly.loadStringFromString(9,string09);
          }

        setBackground(Color.white);

        firefly.landscapeAuthorIs("William Overington" +
                                  "    " +
                                  "WOverington@ngo.globalnet.co.uk");

        font1120 = new Font("SansSerif", Font.PLAIN, 12);
        font1122 = new Font("SansSerif", Font.ITALIC, 12);
        font1180 = new Font("SansSerif", Font.PLAIN, 18);
        font1182 = new Font("SansSerif", Font.ITALIC, 18);
        font1240 = new Font("SansSerif", Font.PLAIN, 24);
        font1242 = new Font("SansSerif", Font.ITALIC, 24);
        font1360 = new Font("SansSerif", Font.PLAIN, 36);
        font1362 = new Font("SansSerif", Font.ITALIC, 36);
        font1480 = new Font("SansSerif", Font.PLAIN, 48);
        font1482 = new Font("SansSerif", Font.ITALIC, 48);
        font1600 = new Font("SansSerif", Font.PLAIN, 60);
        font1602 = new Font("SansSerif", Font.ITALIC, 60);
        font1720 = new Font("SansSerif", Font.PLAIN, 72);
        font1722 = new Font("SansSerif", Font.ITALIC, 72);

        obeycode=1;

        setFont(font1120);

        fontcode = 1120;
      }

    public void actionPerformed(ActionEvent event)
      {
        Object source = event.getSource();

        if (source == go1Button)
          {
            obeycode=51;  // the label in the 1456 code where
                          // obeying should start
                          // if the "go1" button is clicked
            repaint();
          }
      }

    public void itemStateChanged(ItemEvent event)
      {
        Object source = event.getSource();

        if(source == radio91)
          {
            obeycode=91;
            firefly.integer1456Set(1,obeycode);
          }

        if(source == radio92)
          {
            obeycode=92;
            firefly.integer1456Set(1,obeycode);
          }

        if(source == radio93)
          {
            obeycode=93;
            firefly.integer1456Set(1,obeycode);
          }

        if(source == radio94)
          {
            obeycode=94;
            firefly.integer1456Set(1,obeycode);
          }

        if(source == radio95)
          {
            obeycode=95;
            firefly.integer1456Set(1,obeycode);
          }
        
        repaint();
      } 
 

    public void mousePressed(MouseEvent e)
      {
        pressx=e.getX();
        pressy=e.getY();
        shiftdown=e.isShiftDown();
        controldown=e.isControlDown();
        altdown=e.isAltDown();
        firefly.integer1456Set(5,pressx);
        firefly.integer1456Set(6,pressy);
        if (shiftdown)
          {
            firefly.integer1456Set(7,1);
          }
        else
          {
            firefly.integer1456Set(7,0);
          }
        if (controldown)
          {
            firefly.integer1456Set(8,1);
          }
        else
          {
            firefly.integer1456Set(8,0);
          }
        if (altdown)
          {
            firefly.integer1456Set(9,1);
          }
        else
          {
            firefly.integer1456Set(9,0);
          }

        if (splittheeventhandler)
          {
            if (pressy < 350)
              {
                obeycode = 70;
              }
            else
              {
                if (pressx < 100)
                  {
                    obeycode = 71;
                  }
                else if (pressx < 200)
                  {
                    obeycode = 72;
                  }
                else if (pressx < 300)
                  {
                    obeycode = 73;
                  }
                else if (pressx < 400)
                  {
                    obeycode = 74;
                  }
                else if (pressx < 500)
                  {
                    obeycode = 75;
                  }
                else if (pressx < 600)
                  {
                    obeycode = 76;
                  }
                else if (pressx < 700)
                  {
                    obeycode = 77;
                  }
              }
          }
        else
          {
            obeycode=41;
          }
        repaint();
      }

    public void mouseReleased(MouseEvent e)
      {

      }

    public void mouseClicked(MouseEvent e)
      {

      }

    public void mouseEntered(MouseEvent e)
      {
       
      }

    public void mouseExited(MouseEvent e)
      {
       
      }

    public void paint(Graphics screen)
      {

        chooseFont(screen);

        resultchar =
          firefly.obeySoftwareAtLabel(screen,obeycode);

        if (resultchar == '?')
          {
            do
              {
                int functionchoice=
                  firefly.softwareinterruptparameterGet();

                if (functionchoice == 1)
                  {
                    firefly.string1456Set
                      (19,"The 1456 engine in action.");
                  }

                if (functionchoice == 11)
                  {
                    splittheeventhandler = true;
                  }

                if (functionchoice == 12)
                  {
                    splittheeventhandler = false;
                  }

                if (functionchoice == 21)
                  {
                    colourtoolbarison = true;
                    screen.setColor(Color.red);
                    screen.fillRect(0,350,100,50);
                    screen.setColor(Color.orange);
                    screen.fillRect(100,350,100,50);
                    screen.setColor(Color.yellow);
                    screen.fillRect(200,350,100,50);
                    screen.setColor(Color.green);
                    screen.fillRect(300,350,100,50);
                    screen.setColor(Color.blue);
                    screen.fillRect(400,350,100,50);
                    screen.setColor(Color.magenta);
                    screen.fillRect(500,350,100,50);
                    screen.setColor(Color.cyan);
                    screen.fillRect(600,350,100,50);
                  }

                if (functionchoice == 22)
                  {
                    colourtoolbarison = false;
                    screen.setColor(Color.white);
                    screen.fillRect(0,350,700,50);
                  }

                if (functionchoice == 91)
                  {
                    radio91.setState(true);
                  }

                if (functionchoice == 92)
                  {
                    radio92.setState(true);
                  }

                if (functionchoice == 93)
                  {
                    radio93.setState(true);
                  }

                if (functionchoice == 94)
                  {
                    radio94.setState(true);
                  }

                if (functionchoice == 95)
                  {
                    radio95.setState(true);
                  }
                
                if ((functionchoice > 1000) &
                    (functionchoice < 6999))
                  {
                    fontcode=functionchoice;
                    chooseFont(screen);
                  }

                resultchar =
                firefly.obeySoftwareAfterSoftwareInterrupt(screen);
              } while (resultchar == '?');
          }

      }

    public void chooseFont(Graphics screen)
      {
        switch (fontcode)
          {
            case 1120:
              screen.setFont(font1120);
              break;
            case 1122:
              screen.setFont(font1122);
              break;
            case 1180:
              screen.setFont(font1180);
              break;
            case 1182:
              screen.setFont(font1182);
              break;
            case 1240:
              screen.setFont(font1240);
              break;
            case 1242:
              screen.setFont(font1242);
              break;
            case 1360:
              screen.setFont(font1360);
              break;
            case 1362:
              screen.setFont(font1362);
              break;
            case 1480:
              screen.setFont(font1480);
              break;
            case 1482:
              screen.setFont(font1482);
              break;
            case 1600:
              screen.setFont(font1600);
              break;
            case 1602:
              screen.setFont(font1602);
              break;
            case 1720:
              screen.setFont(font1720);
              break;
            case 1722:
              screen.setFont(font1722);
              break;
         } // end of switch block
  
      }

    public void update(Graphics screen)
      {
        paint(screen);
      }

  } 

The HTML file is shown in the next section.

1456 object code

Copyright 2000 William Overington