applet tag requires code attribute.

applet tag requires code attribute.

import java.applet.*;

import java.awt.*;

import java.awt.image.*;

            /*<applet code=Lavatron.class width=590 height=130>

            <param name="img" value="swsm.jpg">

            <applet/>

            */







            public class Lavatron extends Applet implements Runnable{



                int scrollX;

                int bulbsW,bulbsH;

                int bulbS=8;

                Dimension d;

                Image offscreen,bulb,img;

                Graphics offgraphics;

                int pixels[];

                int pixscan;

                IntHash clut=new IntHash();

                boolean stopFlag;



            public void init(){



            d=getSize();

            int offw=(int) Math.ceil(d.width/bulbS)* bulbS;

            int offh=(int) Math.ceil(d.height/bulbS)* bulbS;

            offscreen=createImage(offw,offh);

            offgraphics=offscreen.getGraphics();

            bulbsW=offw/bulbS;

            bulbsH=offh/bulbS;

            bulb=createBulbs(bulbS,bulbsH*bulbS);



            try{

                img=getImage(getDocumentBase(),getParameter("img"));

                MediaTracker t= new MediaTracker(this);

                t.addImage(img, 0);

                t.waitForID(0);

                pixscan=img.getWidth(null);

                int h=img.getHeight(null);

                pixels=new int[pixscan *h];

                PixelGrabber pg= new PixelGrabber(img,0,0,pixscan,h,pixels,0,pixscan);

                pg.grabPixels();



                }catch(InterruptedException e){};

                scrollX=0;

                offgraphics.setColor(Color.black);

                offgraphics.fillRect(0,0,d.width,d.height);

                for(int x=0;x<bulbsW;x++)

                offgraphics.drawImage(bulb,x*bulbS,0,null);

                                 }



            Image createBulbs(int w,int h){



            int pixels[]=new int[w*h];

            int bulbBits[]={

                    0,0,1,1,1,1,0,0,

                    0,1,2,1,1,1,1,0,

                    1,2,1,1,1,1,1,1,

                    1,1,1,1,1,1,1,1,

                    1,1,1,1,1,1,1,1,

                    1,1,1,1,1,1,1,1,

                    0,1,1,1,1,1,1,0,

                    0,0,1,1,1,1,0,0};



            int bulbCLUT[]={0xff000000,0x00c0c0c0,0xffffffff};

            for(int i=0;i<w*h;i++)

            pixels[i]=bulbCLUT[bulbBits[i % bulbBits.length]];

            return createImage(new MemoryImageSource(w,h,pixels,0,w));

                                            }



            public final Color color(int x,int y){



            int p=pixels[y*pixscan+x];

            Color c;



            if((c=(Color)clut.get(p))==null)

            clut.put(p,c=new Color(p));

            return c;

                                    }



            public void update(){}



            public void paint(Graphics g){

            offgraphics.copyArea(bulbS,0,bulbsW*bulbS-bulbS,d.height,-bulbS,0);



              for(int y=0;y<bulbsH;y++){

               offgraphics.setColor(color(scrollX,y));

               offgraphics.fillRect(d.width-bulbS,y*bulbS,bulbS,bulbS); 

                                      }

               offgraphics.drawImage(bulb,d.width-bulbS,0,null);

               g.drawImage(offscreen,0,0,null);

               scrollX=(scrollX+1) % pixscan;



                               }



            Thread t;

            public void run(){

            while(true){

            paint(getGraphics());

            try{

            t.yield();

                }catch(Exception e){};

            if(stopFlag)

            break;

                    }

            }

            public void start(){

            t=new Thread(this);

            t.setPriority(Thread.MIN_PRIORITY);

            stopFlag=false;

            t.start();

                        }







            public void stop(){

            stopFlag=true;

                       }



        }





            class IntHash{



            private int capacity;

            private int size;

            private float load=0.7f;

            private int keys[];

            private  Object vals[];



            public IntHash(int n){

                capacity =n;

            size=0;

            keys=new int[n];

            vals=new Object[n];              

                     }



            public IntHash(){

                this(101);

                    }



            private void rehash(){

            int newcapacity=capacity*2+1;

            Object newvals[]=new Object[newcapacity];

            int newkeys[]=new int[newcapacity];



            for(int i=0;i<capacity;i++){

            Object o=vals[i];



            if(o!=null){

            int k=keys[i];

            int newi=(k & 0x7fffffff) % newcapacity;

            while(newvals[newi]!=null)

            newi=(newi + 1) % newcapacity;

            newkeys[newi]=k;

            newvals[newi]=o;

                                               }            

                                 }

            capacity=newcapacity;

            keys=newkeys;

            vals=newvals;

                          }



            public void put(int k,Object o){

            int i=(k & 0x7fffffff) % capacity;

            while(vals[i]!=null && k!=keys[i])

                i=(i+1) % capacity;

            if(vals[i]==null)

                size++;

            keys[i]=k;

            vals[i]=o;

            if(size>(int)(capacity*load))

            rehash();             

                      }



            public final Object get(int k){

            int i= (k & 0x7fffffff) % capacity;

            while(vals[i]!=null && k!=keys[i])

                i=(i+1) % capacity;

            return vals[i];             

                               }

            public final boolean contains(int k){

            return get(k)!=null;

                                 }

            public int size(){

            return size;

                     }

            public int capacity(){

            return capacity;             

                          }



                            }
View Answers









Related Tutorials/Questions & Answers:
<applet> tag requires code attribute.
applet tag requires code attribute.  import java.applet.*; import java.awt.*; import java.awt.image.*; /*<applet code...="swsm.jpg"> <applet/>
Applet Tag Parameters,Applet Tag in HTML
the applet's operation. APPLET parameters stored in the PARAM tag actually have little.... Second, add necessary code to the applet to retrieve these parameter values... <APPLET> Tag Parameters: The <PARAM> Tag
Advertisements
applet program code - Applet
applet program code  hello sir, i did't get the code for below problem... please help me... 1.An applet program to draw a line graph for y=2x+5.[for suitable values of x & y
The APPLET Tag in Detail
the applet's code. The document's URL is used. if this attribute... lets explore the APPLET tag now. The format of this tag is given below: [<... [</]APPLET[>]  <APPLET> Tag Attributes in detail.The three
Applet code parameter - Applet
Applet code parameter  Hi... I've designed an applet where i placed... How can i get that class... I used code="MyProgram.class" codebase="WEB-INF/classes" but this didn't worked i also tried code="WEB
attribute in action tag - Java Beginners
attribute in action tag  I'm just a beginner to struts. The name tag(name="bookListForm") is used to define the form used with the action class. But i`m not clear about the attribute tag(attribute
applet code - Java Beginners
applet code  hi friends.. i have to oen one applet, in that applet code should be apper what we have written for the applet... this is my...://www.roseindia.net/java/example/java/applet/ Hope that it will be helpful
Crop Image Code in Applet
Crop Image Code in Applet  Sir, Can somebody please provide me with code to crop and save an image in applet
Crop Image Code in Applet
Crop Image Code in Applet  Sir, Can somebody please provide me with code to crop and save an image in applet
Java code - Applet
Java code  I want java applet code for drawing an indian flag
insertion sort applet code
insertion sort applet code  i need Insertion Sort Applet Program
servlet code - Applet
servlet code  how to communicate between applet and servlet  Hi Friend, We are providing you the code that will display the message sent from the servlet to applet. Here is the code of 'ServletExample.java
Java Code - Applet
Java Code  How to Draw various charts(Pie,Bar,and Line etc.)using Applet
Rel attribute in area tag, Use of rel attribute in area tag.
Rel attribute in area tag, Use of rel attribute in area tag. In this tutorial, you will see the use of rel attribute of area tag and how to implement...;>Text Area</area> Example of rel attribute: Code:areatag
JSP Applet Tag - JSP-Servlet
JSP Applet Tag  Hi, I am using Eclipse Ganymede. I have develloped... and my applet(Basic Hello World Applet) under Java Resources folder. I have jsp plugin type as applet in my jsp. When I run this jsp on Server(Tomcat6.0
HTML tags, Definition of applet tag in HTML5.
HTML tags, Definition of applet <applet> tag in HTML5. In this section, we will define applet tag. HTML5 does not support applet tag. Applet tag... instead of applet tag <applet>
Target attribute in anchor tag, Use of target attribute of anchor tag in HTML5.
Target attribute in anchor tag, Use of target attribute of anchor tag in HTML5. In this tutorial, we will see the use of target attribute of anchor tag...="value">Text Area</a> Example of target attribute: Code
flush attribute in jsp:include tag - JSP-Servlet
flush attribute in jsp:include tag  what is the use of flush attribute in jsp:include tag ?  hi friend, ------------------------------ Read for more information, http://www.roseindia.net/jsp
HTML5 <area> href, hreflang attribute of area tag.
;area> tag in html5. href: The href attribute specifies the URL link for the area tag in the image map; each tag have a link. hreflang: This attribute...; The attribute value refers to the language code, which is two letter
HTML5 audio loop, Use of loop attribute of audio tag in  HTML5.
HTML5 audio loop, Use of loop attribute of audio tag in  HTML5. Introduction:Loop attribute is used for reputation of audio or music. It repeats...; ADS_TO_REPLACE_1 Example of  loop attribute in HTML5: Code
Anchor tag attributes in HTML5, Define the type attribute of anchor tag.
  In this tutorial, we will see the use of type attribute of anchor tag . The type attribute of anchor tag specifies the MIME (multipurpose internet... syntax of type attribute in anchor tag.      
Rel attribute in anchor tag, Use of rel attribute in anchor tag.
Rel attribute in anchor tag, Use of rel attribute in anchor tag. Description:You will see the use of rel attribute of anchor tag and how to implement... of rel attribute: Code: hrefAttributeTag.html <!DOCTYPE html>
Code Problem - Applet
Code Problem  How to set a background color for frame and panel ...? What is the difference btw these two(in setting background color)..?  Hi Friend, If you simply want to set background color for panel, try
HTML5 type attribute, Definition of type attribute in <area> tag.
HTML5 type attribute, Definition of type attribute in <area> tag. This tutorial will inform you about <area>tag type attribute. The type... is set in the <area> tag. This attribute informs the browser about the type
Hreflang Attribute, Use of hreflang attribute of anchor tag in HTML5.
Hreflang Attribute, Use of hreflang attribute of anchor tag in HTML5. In this tutorial, we will see the use of hreflang attribute and how to implement... Area</a> Example of hreflang attribute: Code: hrefLangAttribute.html
HTML5 audio autoplay, Use of autoplay attribute in audio tag.
HTML5 audio autoplay, Use of autoplay attribute in audio tag. Introduction:The autoplay is an audio tag attribute. It is only supported by HTML5. When it is present in audio tag, the music file will begin itself. or After loading
Anchor tag attributes in HTML5, Define the href attribute of anchor tag.
attribute of anchor tag: Code: hrefAttributeTag.html <!DOCTYPE ...Anchor tag attributes in HTML5, Define the href attribute of anchor tag. In this tutorial, we will see the use of href attribute of anchor tag . The href
HTML5 audio autobuffer, Use of autobuffer attribute in audio tag.
HTML5 audio autobuffer, Use of autobuffer attribute in audio tag. Introduction:The autobuffer attribute has Boolean value. It is available in audio tag...; <body> <p><b>Example of audio tag autobuffer attribute
ModuleNotFoundError: No module named 'pandoc-code-attribute'
ModuleNotFoundError: No module named 'pandoc-code-attribute'  Hi...: No module named 'pandoc-code-attribute' How to remove the ModuleNotFoundError: No module named 'pandoc-code-attribute' error? Thanks   Hi
Custom Tag example with no attribute and no body
Custom Tag example with no attribute and no body... to make custom tag with no attribute and no body This example demonstrates how one can make custom tag in JSP that has no attribute and no body. There are only
html5 required attribute, Example of required attribute of &lt;textarea&gt; tag in html5
html5 required attribute, Example of required attribute of <textarea> tag in html5 In this tutorial, We will introduce you about the required attribute of the <textarea> tag in html5. This attribute is used to specify
html5 placeholder attribute, Example of placeholder attribute of &lt;textarea&gt; tag in html5
html5 placeholder attribute, Example of placeholder attribute of <textarea> tag in html5 In this tutorial, We will introduce you about the placeholder attribute of the <textarea> tag in html5. This attribute is used
html5 maxlength attribute, Example of maxlength attribute of &lt;textarea&gt; tag in html5
attribute of the <textarea> tag in html5. This attribute is used to specify...; Declaration Syntax:   The attribute is used as in the <textarea> tag...html5 maxlength attribute, Example of maxlength attribute of <textarea>
html5 readonly attribute, Example of readonly attribute of &lt;textarea&gt; tag in html5
; tag in html5 In this tutorial, We will introduce you about the readonly attribute of the <textarea> tag in html5. This attribute is used to specify...;  The attribute is used as in the <textarea> tag: <
HTML5 input attribute, Define the type, alt and image  of input tag.
HTML5 input attribute, Define the type, alt and image  of input tag. Introduction:Here we will introduce you to about the type attribute of input tag... attribute of input tag in HTML5.        
Attribute dojoType invalid for tag iterate according to TLD - Ajax
Attribute dojoType invalid for tag iterate according to TLD   Attribute dojoType invalid for tag iterate according to TLD what should i do if i want to implement it on previously developed Struts application
html5 autofocus attribute, Example of autofocus attribute of &lt;textarea&gt; tag in html5
html5 autofocus attribute, Example of autofocus attribute of <textarea> tag in html5 In this tutorial, We will introduce you about the autofocus attribute of the <textarea> tag in html5. This attribute is used to specify
html5 disabled attribute, Example of disabled attribute of &lt;textarea&gt; tag in html5
; tag in html5 In this tutorial, We will introduce you about the disabled attribute of the <textarea> tag in html5. This attribute is used to specify...; The attribute is used as in the <textarea> tag: <textarea
HTML5 colspan attribute, Definition of colspan attribute of &lt;td&gt; tag in html5
HTML5 colspan attribute, Definition of colspan attribute of <td> tag in html5 In this discussion, We will introduce about the use of colspan attribute of <td> tag in html5. This attribute is used for specifying the number
HTML5 rowspan attribute, Definition of rowspan attribute of &lt;td&gt; tag in html5
HTML5 rowspan attribute, Definition of rowspan attribute of <td> tag in html5 In this discussion, We will introduce about the use of rowspan attribute of <td> tag in html5. This attribute is used for specifying the number
In tag files,does attribute values accept expressions or not? If not please explain the reason
In tag files,does attribute values accept expressions or not? If not please... org.apache.jasper.JasperException: /demo1.jsp(20,5) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
Applet run with appletviewer but not in browser, any code problem.
Applet run with appletviewer but not in browser, any code problem.  Hi,My problem is when I am running my applet in appletviewer index.html, Its work... the 52 cards will be show in browser as by "appletviewer" and run as "java applet" I
Achor tag. Struts2 code - Struts
Achor tag. Struts2 code  Hi All, How to send the values form one jsp page to another using anchor tag (or any which is similar to achor) in Struts? Please help me. I am waiting for the answer. Regards, Sandeep
Applet
Applet  I have a java applet that has a button. On clicking the button it should disappear and another applet should appear. How to write this code???? Also in login applet after successful login it should display admin applet
Achor tag. Struts2 code - Struts
Achor tag. Struts2 code  Hi All, How to send the values form one jsp page to another using anchor tag (or any which is similar to achor) in Struts? Please help me. I am waiting for the answer. Regards, Sandeep  
Applet
Applet  Write an applet to display a string in an applet. String should be passed as a parameter to an applet
applet
applet  What is the immediate superclass of the Applet class
applet
applet  Explain different stages in the lifecycle of an applet with figure.   Stages of Applet: Life cycle of an Applet: init(): This method is called to initialized an applet start(): This method is called after
Applet
Applet  Give the class hierarchy of an Applet class
Applet
Applet  how to run an applet on a web browser

Ads