How to make action on each word in the label?
I have a label in the frame I want to make mouse event if the user click on the first word . and onther action if he pressed on the word and so on?I make mouseListener but I do not how to implement this thing.This is the code.
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class TestLinkedLabel extends JFrame implements MouseMotionListener,MouseListener
{
static TestLinkedLabel ob;
JLabel l;
public TestLinkedLabel()
{
setLayout(new FlowLayout());
l=new JLabel("<html><u>Click me to open link</u></html>");
l.addMouseListener(this);
l.addMouseMotionListener(this);
add(l);
l.setForeground(Color.blue);
setSize(400,300);
setVisible(true);
}
public void mouseMoved(MouseEvent e){}
public void mouseDragged(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void mouseEntered(MouseEvent e)
{
l.setCursor(new Cursor(12));
}
public void mouseReleased(MouseEvent e){}
public void mouseExited(MouseEvent e)
{
l.setCursor(new Cursor(0));
}
public static void main(String s[])
{
ob=new TestLinkedLabel();
}
}

