• Post Reply Bookmark Topic Watch Topic
  • New Topic

Display arrow button over label icon on focus

 
Deepu James
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have JLabel displayed on one of my JTable cells. One of the label has Icon image displayed over it. I would like to display arrow button on mouse over Jlabel and displat next ImageIcon on the label when I click on the arrow.
How can I diplay small arrows over a Jlabel Image component when mouse is moved over it? Any help or sample code for this would be very helpfull

Thanks
DJ
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allow me to quote parts of your post out of order.

Originally posted by Deepu James:
How can I diplay small arrows over a Jlabel Image component when mouse is moved over it? Any help or sample code for this would be very helpfull


You can add a MouseListener to your JLabel instance and play tricks
with its icon and/or paint() method. However, it may be easier to
just use a JButton. JButton has some built-in rollover support, and
it's not hard to make a JButton look like a label.



I have JLabel displayed on one of my JTable cells. One of the label has Icon image displayed over it. I would like to display arrow button on mouse over Jlabel and displat next ImageIcon on the label when I click on the arrow.


But in the context of JTable cells, things are different. That's because
the contents of JTable cells (possibly excluding the cell being edited)
are not Components. What you see in a cell is the image of its renderer
Component, but there's no point adding listeners to the renderer Component
(or trying to use rollover) because it's not there anymore by the time
you move your mouse over it.
For that I guess you would need to add a MouseMotionListener for the
entire JTable, then either cause specific cells to be repainted or
draw on top of the cells.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!