This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Applets and the fly likes i'm getting an error start:applet not intialized. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "i Watch "i New topic
Author

i'm getting an error start:applet not intialized.

malhar deshpande
Greenhorn

Joined: Nov 12, 2011
Posts: 5
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

/*<applet code="demo13" width=300 height=200>
</applet>
*/

class Lines extends Applet implements MouseListener{

int mousex=0,mousey=0,movx=0,movy=0;

public void init(){

addMouseListener(this);

}


public void mouseExited(MouseEvent me){
}

public void mouseEntered(MouseEvent me){
}

public void mouseClicked(MouseEvent me){
}

public void mousePressed(MouseEvent me){

mousex=me.getX();
mousey=me.getY();
repaint();
}

public void mouseReleased(MouseEvent me){

movx=me.getX();
movy=me.getY();
repaint();
}

public void paint(Graphics g){

g.drawLine(mousex,mousey,movx,movy);

}
}
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2095
    
    7
Its hard to tell what you are doing since we don't see the HTML you are using to invoke the applet.

However based on the comment in your code you may not be specifying the applet class correctly.

Your class is called "Line" so the applet code value should be "Line.class", not "demo13".
malhar deshpande
Greenhorn

Joined: Nov 12, 2011
Posts: 5
hi...
wih the help of above code i'm trying to draw lines just like in "paint".that's why i am using 4 integer variables to get the coordinates of the inital and final position of the cursor.
thanks for your reply but your suggestion didn't work.its still giving the same error.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19556
    
  16

I'll move this thread to our Applets forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
malhar deshpande
Greenhorn

Joined: Nov 12, 2011
Posts: 5
ok i resolved the problem

i made corrections as told to me in above posts and in addition i didn't declare the class public.Now the program is working but i am not able to hold the lines,they vanish as soon as they are created....reply me as soon as possible.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2095
    
    7
i am not able to hold the lines,they vanish as soon as they are created


See: Custom Painting Approaches.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: i'm getting an error start:applet not intialized.
 
Similar Threads
unusual behaviour of subclass of JPanel
Not able to compile
MouseMotionListener
TextField Population of Mouse Events?
Hand Cursor