• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);

}
}
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 22800
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll move this thread to our Applets forum.
 
malhar deshpande
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i am not able to hold the lines,they vanish as soon as they are created



See: Custom Painting Approaches.
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic