Thursday 15 July 2010

java - No applet found error? -


I am writing a program for a class where the national flag should be flagged for the national anthem on the American flag scale. I got the code but got an error that the applet is still not found, though it is not here I am using Eclipse

Code:

  @SuppressWarnings ("Serial") anyone can help me with the public? Class Lab 5b Jepllet {Private Audio Clip Audio Clip; Public Labs 5b (Add) (New ImagePanel ()); URL urlForAudio = getClass (). GetResource ("audio / us.mid"); Audioclip = applet NAU Audio Clip (URLForAudio); Audioclip.loop (); } Public Zero Start () {If (audio clip! = Zero) audioclip.loop (); } Public Zero Stop () {If (audio clip! = Tap) audioclip.stop (); } / ** Main Method * / Public Stable Zero Main (string [] ARG) {// Create a frame Jeffrey Frame = New JFram ("Lab 5"); // Make an example of Apple Lab 5B applet = New Lab 5b; Applet.init (); // Add applet example to frame frame. ADD (applet, java.at.birdlutut.cer); Frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // Display frame frame .Setset (200, 660); Frame.setVisible (true); }} @SuppressWarnings ("serial") class ImagePanel JPanel extended {private image icon imageIcon = new ImageIcon ("image / us.gif"); Private image image = imageIcon.getImage (); Private int y = 550; Public Image Panel () {Timer Timer = New Timer (120, New Timer Listener); Timer.start (); } Class timer listener verifies Alicer {Public Zero ActionPerfed (Action Event e) {increaseY (); }} Public Nil rise Y () {if (y>; 0) {y--; Repaint (); }} / ** Drag image to panel * / Protected Waste Paint Comonant (Graphics G) {SuperPaintConant (G); If (image! = Null) {g.fillRect (0, 0, 10, 660); G.drawImage (Image, 11, Y, 160, 84, this); }}}   

Enter the code here

Many things for

  • applets main () do not begin execution in the method. However, if you expand your class , then it is possible to execute applets by using the Java interpreter method ( main <) > Frame .

  • It is important to have the init () method because it's the browser or applet viewer to notify this applet It is always loaded in the system. It is always called for the first time that the start method is called.

  • JFrame and JApplet All the top levels, instead of adding the containers and the applet to frames , I would like to create an object of the JPanel because it has both the JFrame / JApplet can be added in your case. Just add ImagePanel to your top-level container.

  • To access the files on the hard disk,

  • I / O stream Applet for This is not possible.

    Read more

No comments:

Post a Comment