Request For Enhancement: Cell Renderers: Is the Mouse In the Cell?

I would like to propose an enhancement to Cell Renderers: add some way for Cell Renderers to know if the mouse is currently over the cell being renderered. Currently, Cell Renderers are told only if a cell is SELECTED or has FOCUS, which are not the same thing.
This would be of great help especially for JTable and JTableHeader, where one could provide visual feedback as the mouse moves across cells, which could be a great help for the visually impaired.

Hi, Marsian -
You are absolutely right about adding methods to interfaces. My mistake.
And you are also correct that what I propose would require that cells be repainted as the mouse enters or exits that cell's bounds. If this were to prove too expensive for some applications, the JComponents that use CellRenderers could have a property to enable or disable the behavior, for example setTrackMouseMovements(boolean). But when compared to what happens when you scroll a JTable, I cannot imagine this would be anywhere nearly as expensive, and the rendering that scrolling requires--all the cells that come into view within the viewport after scrolling--seems to work just fine.
Heck, even when you select a cell, a whole lot of cells are re-rendered. Also, when a tooltip is currently visible, if you move the mouse, the CellRenderer is consulted for each and every mouse movement, even within the same cell!!!. This seems to work fine too. Would re-rendering a cell as the mouse enters or exits its bounds by anywhere nearly as expensive?
But you write something that still confuses me. Are you saying that you create a new Component each and every time the getXXXRendererComponent() method of your CellRenderer is called? I don't understand why one would want to do this. Can you please help me out here?
I would think that only one instance of each Component sub-class that the CellRenderer might return would be more than good enough. And I would think that these instances would be created in the CellRenderer's constructor. Certainly, the default CellRenderer classes do not create a new Component each time a cell needs to be renderered. In fact, most of them actually extend an extension of JComponent themselves, i.e. JLabel, and return "this". No CellRenderer I have ever written has ever created a Component each time a cell is rendered. That would be very expensive.
But still, your point about altering interfaces is well taken. Too bad.
There must be some solution to this problem. JTable could provide the cell coordinates of the cell in which the mouse currently resides, for instance, or it could have a method that indicates if the mouse is currently over a cell with given coordinates.
Thanks,
---Mark

Similar Messages

  • Request For Enhancement: Add method mouseIn() to JComponent

    I would like to propose that a new method be added to JComponent. This method would return boolean true if the mouse is currently over the JComponent and false if not. Method signature: public boolean mouseIn().
    This method would make it easier to accomplish visual feedback for when the mouse is over any JComponent, similar to how rollover can be done for AbstractButton.
    Currently, the best method I can come up with is to add a MouseListener that records the state from the mouseEntered() and mouseExited() events. I add my own method mouseIn() that returns that state. Then method paintComponent() can check this state by calling mouseIn() and paint the component accordingly.
    At first I thought the MouseListener should be added in each and every constructor of each and every JComponent, but then realized actually, the place to provide this feedback is in the ComponentUI class for each JComponent, as part of a custom Look & Feel. What I have come up with is to add the MouseListener to the JComponent in the ComponentUI's createUI() method, recording the state in the ComponentUI instance. The problem with this is, it makes it impossible for the ComponentUI to be a singleton like most of the ComponentUI classes are for the standard L&F's. This requires that each JComponent instance have its own ComponentUI instance.
    If JComponent had this proposed mouseIn() method, the ComponentUI methods could simply call this method, and the ComponentUI would not have to record JComponent-instance-specific state. There would not be a need for so many instances of ComponentUI and MouseListener.

    Hi,
    imho this request for enhancement is much better than your other onces. In fact monitoring this state is more than just using mouseEntered(..) and mouseExited(...) - if there is a method, it must return a valid state - if mouse has entered and you make the component invisible, mouse does not exit before that takes place - if you open another application which covers this component, mouse does also not exit before, but the component stays visible - you see, there are much more things to control, to get a valid state at any time. And mouseIn() is an ugly name and says less - why not isMouseOver() or something like this?
    Another thing is, why do you request this for JComponent?- Should java.awt.Component not get this feature in your opinion?
    greetings Marsian

  • I can't get imovie to open after trying to shift the image to my TV by clicking fn F3.  If I hold the mouse on the imovie icon for a few seconds the imovie window opens but if I click anywhere on the window it disappears

    I can't get imovie to open after trying to shift the image from my macbook pro to the tv screen like I have done many times before.  If I double click on the imovie icon, imovie doesn't open, but the strip across the top shows iMovie, file, edit , clip, view, text share window help tabs across the top.  The iMovie window will appear if I click on the iMovie icon on the dock for a few seconds, or if I do control F3 at the same time, but when I click on the window it disappears.  When I hover the mouse over the iMovie window that appears the window has a blue border around it.  when I move the mouse outside the iMovie window the blue border goes away.  If I sweep 4 fingers from the top of the screen down, the screen dims a little but the iMovie window doesn't appear. If I click play under the view tab I can hear audio, but still no iMovie window.  It's as if the window is being blocked by the desk top somehow.

    Similar issues here.
    I purchased five movies for download and having nothing but problems getting them downloaded. I keep receiving error messages and the download stops and I have to restart it, just to get another minute worth of download with each restart. Now Apple has my money and I have nothing.

  • I could not remember my apple ID password so I made a request for a new one. When I received the email with the link on resetting my password it was addressed to John Ohare. My name is not John Ohare. Does this mean someone is hacked my iCloud account?

    I could not remember my apple ID password so I made a request for a new one. When I received the email with the link on resetting my password it was addressed to John Ohare. My name is not John Ohare. Does this mean someone has hacked my iCloud account?

    Hello Corinne Craven,
    Thank you for using Apple Support Communities!
    You can update the name on your Apple ID here:
    Appleid.apple.com
    If you suspect unauthorized access to your apple ID I would normally recommend resetting your password, but you have already done this.
    Here is some information about 2 step verification which is another level of security for your account.
    Apple ID: Frequently asked questions about two-step verification for Apple ID
    http://support.apple.com/kb/HT5570
    Be sure to read all the information in the article if you choose to use two-step verification.
    Take care,
    Sterling

  • I forgot how to use the setting, move the mouse to the upper left corner and the windows become smaller for an overview?

    i forgot how to use the setting, move the mouse to the upper left corner and the windows become smaller for an overview?

    I'm not quite sure what you want - if you want an overview of all open windows, use the F key.. Otherwise please post back and be more specific.

  • TS3048 My keyboard will connect wirelessly but my mouse will not. I've put new batteries in the mouse and the green light is blinking but it just won't connect!!! I don't have a 'wired' mouse so I can't get into preferences etc!!! Pls help

    My keyboard will connect wirelessly but my mouse will not. I have tried many times, put new batteries in etc. The Bluetooth appears to be on (as the wireless keyboard is working). I don't have a 'wired' mouse so I can't get into preferences etc. Is the mouse dead perhaps? The green light is flickering so it should be ok???
    Thank you for your help
    Sully (frustrated Irishman)

    From what you say I would suggest the batteries are not connecting properly.
    First, thoroughly clean all contacts, both inside the mouse and the contact points of the batteries.  Use an alcohol based cleaner (whisky will do, hic!)  dampen (not wet) cotton buds for cleaning.
    Then check to see if they fit firmly.   If you can shake your mouse and hear things are loose, that will be the batteries.   Check the make.   Apple and Duracell, in that order, are the best batteries.   Where slight undersizing has been reported they are with other than the foregoing.
    You can resolve the size problem with appropriate packing but that will always be a makeshift solution.  After, reassemble, turn on the mouse and with luck, away you go. 
    Hopefully this will solve your problem but in any case let us know how you get on.
    Message was edited by: seventy one

  • The cursor on my iMac freezes, and I cannot do anything unless I unplug the computer. It is NOT a problem with the mouse or the keyboard ... it is internal. How do I fix this??

    The cursor on my iMac (Panther 10.3.9) freezes to where I cannot do anything unless I unplug the computer. It is NOT a problem with the mouse or the keyboard. How do I solve this problem?

    ClassicII wrote:
    Sorry to say but your imac g5 logic board has bad caps. This was a problem apple had and issued a out of warentee fix but that has now expired.
    The cost to get this repaired is more than what you could find another used imac for.
    I would suggest you get some details before you rush to make a diagnosis. You have absolutely no information to base this on. I see you're hitting up on numerous threads all over the place. Quality, meaning several good posts with reliable advice, is much more worthwhile than quantity.

  • Scroll down with the mouse while the crop tool window is open

    I would like to know if there is a way to scroll down with the mouse while the crop tool window is open, like in Acrobat 5.0. If not with the mouse, is there another shortcut to go through the pages and adjust the size of the crop and see it on different pages? Thanks!

    Yes, but I won't see what I'm cropping if I cannot scroll down while the window is open. Thank you for answering anyway!

  • Can't write automation with anything but the mouse on the track

    I just upgraded to logic studio and now I can't write automation. I click and drag the volume bar on the channel strip, the playback volume goes up, but the automation line does not change. In touch, latch or write modes this occurs. I noticed the problem with my behringer bcf2000, but it happens even when I disconnect the hardware and just use the mouse. The only way I can adjust the automation is to use the mouse in the horizontal track and adjust the lines. I hope there is some simple toggle I need to click to re-enable this. Can anyone help me please? I do not have this problem in logic pro 7

    Hi there!
    I had the same problem, - and found the same answer, - but now I find that the "Write automation for: Volume" checkbox actually unchecks itself... I check it and forget about it but when I come back later in the process to change the volume automation I find it unchecked. This only happens to the volume checkbox though. Any ideas why?

  • Spotlight does not show the path or location of a file anymore when hovering with the mouse over the file

    in Leopard Spotlight used to show you the path /location  of a file when you stayed with the mouse over the result. As sometimes I just look for the location of a file not to open it like a mp3 file. It would be nice to have a opiton in spotlight to contorl or right click a file and then give the option to say show in finder. that only works when you have your results show up in finder first and takes a bit longer. or maybe in the new prieview window to show the loaation or give you opitons what to do with the file
    Just an idea to spotlight even better

    When you hover over a file in spotlight list (or select with up/down arrow) you can also hit command-R to open the folder where the file is located. Kind of like 'Show Original' for aliases.
    But yeah, Apple really needs to just show the directory path on the hover pop-up by default. Obviously, when you do a search you'll most likely get several files with the same name - we need to see the locations to tell them apart. One of the main reasons to do a file search is to simply find out 'where the file is located' - not necessarily open the file. Seems pretty shortsighted to not show the file location in the search result.

  • When safari is in full screen mode and I move the mouse to the top of the screen to bring up the menu bar and the bookmark bar, it does nothing.  Is anyone else having this issue?

    When safari is in full screen mode and I move the mouse to the top of the screen to bring up the menu bar and the bookmark bar, it does nothing.  Is anyone else having this issue?
    Thanks

    I just tested that since I hardly ever use full screen mode, this was the first time since I upgraded to Mountain Lion, and it worked fine for me.
    Try shutting Safari down and see if that changes anything.
    If that doesn't change anything, try shutting down and then rebooting.
    Allan

  • Tooltip show forever until the mouse exists the datagrid column header

    Hi,
    Any idea on showing tooltip forever until the mouse exists the datagrid column header.
    Thanks
    Atul

    Hi JamieVJohnson,
    Please specify the
    GroupStyle.Panel to the
    DataGridRowsPresenter in DataGrid, since the default GroupStyle.Panel (StackPanel) cannot fit for the DataGrid Width "*" and the columns collapse.
    <DataGrid Height="100">
    <DataGrid.GroupStyle>
    <GroupStyle>
    <GroupStyle.Panel>
    <ItemsPanelTemplate>
    <DataGridRowsPresenter/>
    </ItemsPanelTemplate>
    </GroupStyle.Panel>
    <GroupStyle.ContainerStyle>
    <Style TargetType="{x:Type GroupItem}">
    </Style>
    </GroupStyle.ContainerStyle>
    </GroupStyle>
    </DataGrid.GroupStyle>
    <DataGrid.Columns>
    <DataGridTextColumn Header="Column 1" Width="2*"/>
    <DataGridTextColumn Header="Column 2" Width="1*"/>
    </DataGrid.Columns>
    </DataGrid>
    Sincerely,
    Bob Bao
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Are you looking for a typical code sample? Please download
    all in one code framework !

  • How do I right click using the mouse on the mac desktop ?

    how do i right click using the mouse on the mac desktop

    does this involve iPhoto for the Mac in any way?
    the simple answer given no actual information is to press down on the right mouse button
    LN

  • Win 7 moving the mouse hides the menu in Reader XI

    When I move the mouse towards the menu (file, view, etc) in the latest edition of Reader XI, the menu becomes hidden, as if I depressed F9. How do I stop that from happening?

    Thanks for your reply. I have a slightly older version of KIS 2015 but I will give that a try when I get the chance. But, I have 2 computers, both with Win7 Pro and Kaspersky Internet Security 2015. One with 32 bit and the other with 64 bit. No mouse problems on the 64 bit newer computer. It has KIS 15.0.0463b. I'll have to check later which version of KIS 2015 is on the older computer with the problem. It also has a new ASUS 22 inch monitor with a different screen resolution than the computer without the problem. Not sure if that has anything to do with the problem. My guess is no.

  • My itunes opens but then then when i hover the mouse on the itunes window there is just a blue circle

    My itunes opens but then then when i hover the mouse on the itunes window there is just a blue circle

    Hold the shift key upon boot, that will disable any boot loading third party kernel extension files.
    Once you get in:
    1: backup your user file folders to a external storage drive
    2: go around and update all your third party software everywhere, including right clicking on third party system preference panes and removing them if necessary
    3: any third party software that can't be updated, consider removing.
    4: Look in your Console log files for "kernal protection" type messages to get a clue what's causing your problems.
    Read about Gray, White and Blue, Kernel Panics here, they are usually always caused by third party software incompatibilities, but not always.
     Cheat sheet to help diagnose and fix your Mac

Maybe you are looking for

  • Regular expression question (should be an easy one...)

    i'm using java to build a parser. im getting an expression, which i split on a white-space. how can i build a regular-expression that will enable me to split only on unquoted space? example: for the expression: (X=33 AND Y=44) OR (Z="hello world" AND

  • Use 24 in iMac as a screen for mac mini

    Can I use 24 in iMac as screen for mac mini?

  • How do I Limit the number of Clients Per AP, Per Radio

    I'm have WCS, 2 - WLC4404, 1 - WLC4402 and 1 WISM (6509). All running 7.X OS. Here is my problem I have 4 3502 AP,s in the hall, but the laptops all connect to one AP. 2 Clients on A and 26 Clients on G. How do I control this? Mike

  • Error Message while login via iPhone App.

    Hello, after login at iPhone App an error message occurs. "Server connection not possible: Please verify Server host and Port settings." Where I could check it? Used login: Account -> corporate mail Password -> new password from OIM Server -> https:/

  • Getting Runtime error R6025 when I exit Skype

    I am getting this message every time I close Skype.  It says: "R6025 -pure virtual function call" I am running Skype 7.0 and Windows 8.1.  It does not matter if I have been chatting or doing a video call or have done nothing at all.