Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

no mouseClicked when TransferHandler set for JLabel?

 
Mike Mayer
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I extended a JLabel to make it draggable by adding a TransferHandler. The only method in the mouse listener that gets called is mousePressed. I would still like to detect a mouse click on the label. Is there a way to do this? It appears that setting the transfer handler on the component makes it treat any mouse activity as a possible drag.
 
daniel xiao
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can Implements MouseListener,
addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e){ }
});
 
daniel xiao
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to make JLabel text display many rows
Exclusion of this method:
JLabel.setText("<html>hhhhh<br>jjjjjj</html>")
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic