• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Display arrow button over label icon on focus

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic