home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-04-08 | 2.5 KB | 97 lines |
-
- // MultiButton, generated with the Mortar JavaImageHandler gnome
- //
- // Parameters
- // NAME DEFAULT/EX VAL. VALUE FORMAT, DESCRIPTION
- //------------------- --------------- ----------------------------------------
- // backgroundColor 000000 RRGGBB, in base 16 (hexadecimal); 00-FF
-
- import java.applet.Applet;
- import java.awt.*;
- import java.net.*;
- import java.util.*;
-
- public class MultiButton extends Applet
- {
- public Color backgroundColor, foregroundColor;
-
- public boolean threadSuspended=false;
-
- // Image-related variables
- protected int numImages=0;
- protected MediaTracker tracker;
- protected Image imgNormal, imgHighlight;
-
- public void init()
- {
- // Create the foregroundColor as the complementary to the backgroundColor
- backgroundColor = IEExtend.strColor( getParameter( "backgroundColor" ), Color.black);
- foregroundColor = new Color( 255-backgroundColor.getRed(),
- 255-backgroundColor.getGreen(),
- 255-backgroundColor.getBlue() );
- tracker = new MediaTracker( this );
-
- imgNormal = getImage(getDocumentBase(), getParameter("normal"));
- imgHighlight = getImage(getDocumentBase(), getParameter("highlight"));
-
- // tracker.addImage(imgNormal, 0);
- // tracker.addImage(imgHighlight, 1);
-
- repaint();
- }
-
- public void start()
- {
- loadResultMessage = loadImages();
- }
-
- // Mouse button handling code
- public boolean mouseDown(Event event, int x, int y)
- {
- return true;
- }
-
- // This method handles drawing.
- public void paint(Graphics g)
- {
- Dimension d = this.size();
-
- g.drawImage(imgNormal,0,0,this);
- }
-
- protected String loadResultMessage = "";
-
- public String loadImages()
- {
- this.showStatus( "Loading images..." );
- Thread n = Thread.currentThread();
- try
- {
- tracker.waitForAll();
- }
- catch (InterruptedException e)
- {}
- catch(NullPointerException e)
- {}
-
-
- if( tracker.isErrorAny() );
- {
- for( int i=0; i<2; i++ )
- {
- if (tracker.isErrorID(i))
- {
- String message = "Error loading \"image" + i + "\"" ;
- this.showStatus( message );
- return message;
- }
- }
- }
-
- return ("2 images loaded successfully.");
- }
-
- }
-
-
-