Source Code : A label with no indication it has been clicked
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
A label with no indication it has been clicked
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
public class MyLabel extends JLabel {
public MyLabel(String msg) {
super(msg);
addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent me) {
fireActionPerformed(new ActionEvent(MyLabel.this, ActionEvent.ACTION_PERFORMED,
"SecretMessage"));
}
});
}
public void addActionListener(ActionListener l) {
listenerList.add(ActionListener.class, l);
}
public void removeActionListener(ActionListener l) {
listenerList.remove(ActionListener.class, l);
}
protected void fireActionPerformed(ActionEvent ae) {
Object[] listeners = listenerList.getListeners(ActionListener.class);
for (int i = 0; i < listeners.length; i++) {
((ActionListener) listeners[i]).actionPerformed(ae);
}
}
}
Thank with us