what's wrong?

G

Guest

In "extends Label" class that follows, I want, when I click mouse over the object, something happens.
I believe my code is correct but when I click mouse over the object nothing happens...
Can you help me?
------File: h.java--------------------
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class h extends Label implements MouseListener
{
public h() { addMouseListener(this); }
public final void update(Graphics g) { paint(g); }
public final void paint(Graphics g) { ........ }

public void mouseClicked(MouseEvent e){
DoSomething(); // fake function ;-)
}
public void mouseExited(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mousePressed(MouseEvent e){}
}
 
R

Ryan Stewart

In "extends Label" class that follows, I want, when I click mouse over the object, something happens.
I believe my code is correct but when I click mouse over the object nothing happens...
Can you help me?
------File: h.java--------------------
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class h extends Label implements MouseListener
{
public h() { addMouseListener(this); }
public final void update(Graphics g) { paint(g); }
public final void paint(Graphics g) { ........ }

public void mouseClicked(MouseEvent e){
DoSomething(); // fake function ;-)
}
public void mouseExited(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mousePressed(MouseEvent e){}
}

You may have a problem somewhere else in your code because that will compile
and work fine if you define DoSomething() (which should be doSomething())
and get rid of the dots in the paint method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top