wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes code not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "code not working" Watch "code not working" New topic

code not working

vijayalakshmi sundararajan

Joined: Dec 03, 2003
Posts: 4
I tried out this code for freehand drawing using mouse.But its not working for me.Can anyone tell me where I went wrong?
the code i hv written is as below
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Painter extends JFrame
private int xValue = -10, yValue = -10;
public Painter()
super( " Hand free drawing page ");
new Label(" Drag mouse to draw the desired picture "),
new MouseMotionAdapter()
public void mouseDragger( MouseEvent e)
xValue = e.getX();
yValue = e.getY();
public void paint( Graphics g)
public static void main(String arg[])
Painter app = new Painter();
new WindowAdapter()
public void windowClosing(WindowEvent e)
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

You're painting on the JFrame itself, which is covered by the content pane. Make another component, make it listen for mouse movement and paint, and add it to the content pane.

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link: http://aspose.com/file-tools
subject: code not working
Similar Threads
Instance Variable errors for MouseMotionAdapt
Button not appearing and drawString issue
Can't see my Panels!!! Aaarrghhhhh....
Weird error not sure what Im doing wrong
Inheritance problem