home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-12-14 | 3.8 KB | 132 lines |
- import java.awt.*;
- import java.awt.event.*;
- import java.applet.*;
-
- /*
- * the dialer applet
- */
- public class Dialer extends Applet implements ActionListener {
-
-
- AudioClip touchTones[] = new AudioClip[12];
-
- public Button NumberButton1;
- public Button NumberButton2;
- public Button NumberButton3;
- public Button NumberButton4;
- public Button NumberButton5;
- public Button NumberButton6;
- public Button NumberButton7;
- public Button NumberButton8;
- public Button NumberButton9;
- public Button NumberButton0;
- public Button PoundButton;
- public Button StarButton;
- /*
- * called when the applet is loaded
- * load audio clips and add the keypad panel
- */
- public void init () {
-
- int i;
- String name;
-
- for (i=0; i<10; i+=1) {
- name = "touchtone."+i+".au";
- showStatus ("Getting "+name);
- touchTones[i] = getAudioClip (getCodeBase(), name);
- }
- name = "touchtone.star.au";
- showStatus ("Getting "+name);
- touchTones[10] = getAudioClip (getCodeBase(), name);
-
- name = "touchtone.pound.au";
- showStatus ("Getting "+name);
- touchTones[11] = getAudioClip (getCodeBase(), name);
-
- setLayout(new BorderLayout());
-
- //add ("Center", keypad = new Keypad (touchTones));
-
- //Font font = new Font ("Times", Font.BOLD, 14);
-
- Color miscColor = new Color (0, 0, 255);
- //setFont (font);
-
- NumberButton1 = new Button ("1");
- add ("South",NumberButton1);
- NumberButton2 = new Button ("2");
- add ("South", NumberButton2 );
- NumberButton3 = new Button ("3");
- add ("South", NumberButton3 );
- NumberButton4 = new Button ("4");
- add ("South", NumberButton4);
- NumberButton5 = new Button ("5");
- add ("South", NumberButton5);
- NumberButton6 = new Button ("6");
- add ("South", NumberButton6 );
-
- NumberButton7 = new Button ("7");
- add ("South", NumberButton7);
- NumberButton8 = new Button ("8");
- add ("South", NumberButton8 );
- NumberButton9 = new Button ("9");
- add ("South", NumberButton9 );
-
- PoundButton= new Button ("*");
- add ("South", PoundButton );
- PoundButton.setBackground (miscColor);
-
- NumberButton0 = new Button ("0");
- add ("South", NumberButton0);
-
- StarButton = new Button ("#");
- add ("South", StarButton);
- StarButton.setBackground (miscColor);
-
- setLayout (new GridLayout (4, 3, 4, 4));
-
- NumberButton1.addActionListener(this);
- NumberButton2.addActionListener(this);
- NumberButton3.addActionListener(this);
- NumberButton4.addActionListener(this);
- NumberButton5.addActionListener(this);
- NumberButton6.addActionListener(this);
- NumberButton7.addActionListener(this);
- NumberButton8.addActionListener(this);
- NumberButton9.addActionListener(this);
- NumberButton0.addActionListener(this);
- PoundButton.addActionListener(this);
- StarButton.addActionListener(this);
- }
-
- public void actionPerformed (ActionEvent ev)
- {
- Object object1 = ev.getSource();
- if (object1 == StarButton)
- touchTones[10].play ();
- else if (object1 == PoundButton)
- touchTones[11].play ();
- else if (object1 == NumberButton0)
- touchTones[0].play ();
- else if (object1 == NumberButton1)
- touchTones[1].play ();
- else if (object1 == NumberButton2)
- touchTones[2].play ();
- else if (object1 == NumberButton3)
- touchTones[3].play ();
- else if (object1 == NumberButton4)
- touchTones[4].play ();
- else if (object1 == NumberButton5)
- touchTones[5].play ();
- else if (object1 ==NumberButton6)
- touchTones[6].play ();
- else if (object1 == NumberButton7)
- touchTones[7].play ();
- else if (object1 ==NumberButton8)
- touchTones[8].play ();
- else if (object1 == NumberButton9)
- touchTones[9].play ();
- }
- }
-