JAVA 13
Buttons.java Guest on 26th September 2020 07:09:34 PM
  1.  
  2. import java.applet.*;
  3. import java.net.*;
  4. import java.awt.*;
  5.  
  6. public class buttons extends Applet
  7. {
  8.    public void init()
  9.    {
  10.       add(new Button("Yin"));
  11.       add(new Button("Yang"));
  12.    }
  13.  
  14.    public boolean action(Event e, Object arg)
  15.    {
  16.       if (((Button) e.target).getLabel() == "Yin")
  17.       {
  18.          try {getAppletContext().showDocument
  19.                  (new URL("http://www.apple.com"));}
  20.          catch (Exception ex)
  21.          {  /* note: code to handle the exception goes here */ }
  22.       }
  23.       else if (((Button) e.target).getLabel() == "Yang")
  24.            {
  25.               try {getAppletContext().showDocument
  26.                       (new URL("http://www.microsoft.com")); }
  27.               catch (Exception ex)
  28.               { /* note: code to handle the exception goes here */ }
  29.             }
  30.       return true;
  31.  
  32.    } /* end public action */
  33.  
  34. } /* end public class buttons */

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.