Tooltip is shown right outside the desktop - How to move it left to mouse?

Hello,
in my application I create tooltips for a JTable using the celltext when pressing the mouse.
public void jDisturbanceMgmntTable_mousePressed(MouseEvent e)
if (e.getButton() == MouseEvent.BUTTON1)
tooltip.setTipText(ToolTipText);
int x = jDisturbanceMgmntTable.getLocationOnScreen().x + e.getX();
int y =jDisturbanceMgmntTable.getLocationOnScreen().y + e.getY() +20;
PopupFactory popupFactory = PopupFactory.getSharedInstance();
tooltipPopup = popupFactory.getPopup(jDisturbanceMgmntTable, tooltip,x,y);
tooltip.setFont(new java.awt.Font("Courier New", Font.PLAIN, 18));
tooltipPopup.show();
The tooltip is always shown right from the mouse- pointer. If the mainwindow is maximized and I click near the right screen edge, the tooltip is show outside the desktop window.
Normally the tooltip should be moved left the mousepointer :
if(x + "TooltipWindow.getWidth()" > Toolkit.getDefaultToolkit().getScreenSize().x)
x = x - "TooltipWindow.getWidth()"
But that is exactly my problem, I don't know how to get the width of the tooltip window.
Any suggestions?
Message was edited by:
pelle23

@Cesar_Castro
This is a really good idea.
To close the post I want to give the complete working code :
public void jDisturbanceMgmntTable_mousePressed(MouseEvent e)
/* when the left mouse- button is pressed on the JTable*/
if (e.getButton() == MouseEvent.BUTTON1)
/* get the text of the cell the mouse is pointing */
int iRow = jDisturbanceMgmntTable.getSelectedRow();
if (iRow > -1)
Object CellObj = jDisturbanceMgmntTable.getValueAt(jDisturbanceMgmntTable.getSelectedRow(),
jDisturbanceMgmntTable.getSelectedColumn());
String ToolTipText = null;
/*put the cell- text into the ToolTipText string- object*/
if (CellObj != null)
ToolTipText = CellObj.toString();
else
ToolTipText = "...";
/*searching for a linebreak in the text (find out if it is a multi- line text)*/
int first_row=ToolTipText.indexOf("\n");
if(first_row == -1)
first_row=ToolTipText.length();
/* Copy all the letters from the first line to a new object
The idear is that the width of the tooltip in dependend only
on the first line*/
String strFirstRow=ToolTipText.substring(0,first_row);
/*Replacing the formatting- signs to html- code*/
ToolTipText = ToolTipText.replace("\n", "<br>");
ToolTipText = ToolTipText.replace("\t", " ");
ToolTipText = ToolTipText.replace(" ", "?");
ToolTipText = "<html>" + ToolTipText + "</html>";
tooltip.setTipText(ToolTipText);
/* getting the default Tooltip position*/
int x = jDisturbanceMgmntTable.getLocationOnScreen().x + e.getX();
int y =jDisturbanceMgmntTable.getLocationOnScreen().y + e.getY() +20;
//creating the font object for the tooltip
Font font=new Font("Courier New", Font.PLAIN, 18);
//getting the fontmetrics for that font
FontMetrics fontmetrics = tooltip.getFontMetrics(font);
//getting the width in pixel for the first line of text - should be nearly the width of the tooltip
int width_of_text=fontmetrics.stringWidth(strFirstRow);
//getting the width of the desktop
int ScreenWidth = Toolkit.getDefaultToolkit().getScreenSize().width();
//calculating the approx x endposition of the tooltip window
//is the position of the mouse- pointer plus the length of the first line of text adjusting by 10 pixel offset
int toolTipXEndPos = width_of_text+x+10;
// if that position is outside the desktop
if(toolTipXEndPos > ScreenWidth)
//move the window left
x = ScreenWidth - width_of_text -20;
PopupFactory popupFactory = PopupFactory.getSharedInstance();
tooltipPopup = popupFactory.getPopup(jDisturbanceMgmntTable, tooltip,x,y);
tooltip.setFont(font);
tooltipPopup.show();
}

Similar Messages

  • Help! When i connect my "iomega" External hard drive to my mac it does not show in devices or on the desktop, how can i access my hard drive?

    Help! When i connect my "iomega" External hard drive to my mac it does not show in devices or on the desktop, how can i access my hard drive?

    what format your iomega HD is it NTFS , if NTFS try download   http://www.apple.com/downloads/macosx/system_disk_utilities/ntfs3g.html

  • I plug a card into my reader, no show on the desktop. how else do I find it?

    I plug a card into my reader, no show on the desktop. how else do I find it?

    Open a Finder window and it should be listed in the sidebar,

  • I have a macbook pro core i7 mid 2012 And update to the latest version 10.8.4 system after updating the system I have the problem appeared to take off the device and stops at the apple logo for about 5 minutes and then enters the desktop How can I solve t

    I have a macbook pro core i7 mid 2012
    And update to the latest version 10.8.4 system after updating the system I have the problem appeared to take off the device and stops at the apple logo for about 5 minutes and then enters the desktop How can I solve this problem and thank you

    If you have more than one user account, these instructions must be carried out as an administrator.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Step 1
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Enter "BOOT_TIME" (without the quotes) in the search box. Note the timestamps of those log messages, which refer to the times when the system was booted. Now clear the search box and scroll back in the log to the last boot time when you had the problem. Select the messages logged after the boot, during the time something abnormal was happening. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V).
    For example, if the problem is a slow startup taking three minutes, post the messages timestamped within three minutes after the boot time, not before. Please include the BOOT_TIME message at the beginning of the log extract.
    If there are runs of repeated messages, post only one example of each. Don’t post many repetitions of the same message.
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.
    Step 2
    Still in Console, look under System Diagnostic Reports for crash or panic logs, and post the entire contents of the most recent one, if any. In the interest of privacy, I suggest you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if present (it may not be.) Please don’t post shutdownStall, spin, or hang logs — they're very long and not helpful.

  • When i press the command key or shift the sign will appear on the desktop, how to deactivate that?

    when i press the command key or shift the sign will appear on the desktop, how to deactivate that?

    Hi m,
    Go to System Preferences > Universal access > Keyboard and turn off Sticky Keys.

  • Can an American use iTunes from outside the US to download movies?

    Can an American use iTunes from outside the US to download movies?  The Terms & Conditions that just popped up as I was going to download a movie seems to indicate "no."  So Americans traveling abroad are out of luck?

    You can only use the Store for the country that reflects your billing address. This applies worlwide, not just to Americans.

  • The Firefox screen lies slightly to the right od the desktop since installing v5, how can I centre it so as not to lose the right hand part of the screen, I have tried dragging it but it wont move

    The FF screen is about 20mm from the left hand edge of the desktop and I can not move it so that I can read the right part of the FF screen

    I tried the zoom thing but it still didnt resolve my issue   Im gonna try to clarify my issue a little bit more, before the change, my screen when I would surf the web would have the apple logo and safari and file and edit and view buttons at the top left hand of the screen and the upper right hand screen would have the time and the wifi strength and my name and the spotlight box and a volume control but now they dont show while Im browsing the web unless I take my arrow and move it to the very top of the screen then those boxes will drop down like it used to be but when I take my arrow and move it from the top of the screen it disappears again and ll I get is a back and forward arrow and the url input bar.  Anyone else have any ideas of what I did to mess this up?

  • How do I remove the Skype icon from the desktop that is on my left on the taskbar ?

    Greetings to all, I have a Windows 7. 64--bit with SP--1. I have been unable, by searching, to find a way to remove the Skype icon from the desktop. It is on my left on the taskbar. Do I need to remove it in the registry ? If yes, how ? Thank you Ldxrunner

    Hi,
    Are you trying to remove Skype entirely, or just get rid of the tool tray icon?
    IIRC, you get that icon as long as Skype is running in the background.  There's a checkbox in Skype options that will keep it from running on startup.  That will eliminate the icon but you won't get notified for incoming calls.
    Z.
    The large print: please read the Community Participation Rules before posting. Include as much information as possible: model, machine type, operating system, and a descriptive subject line. Do not include personal information: serial number, telephone number, email address, etc.  The fine print: I do not work for, nor do I speak for Lenovo. Unsolicited private messages will be ignored. ... GeezBlog
    English Community   Deutsche Community   Comunidad en Español   Русскоязычное Сообщество

  • TS2094 the page on the screen is fully to the right of the screen how is it possible to centralize to the middle thanks for any help

    would appreciate any help on this matter how to centralize the window it is fully to the right of the screen it is an imac 20" 2006 model

    Even when I move the screen far to the right as I can, there is at least a pixal or two that I can drag to the left.
    Are you wanting to auto center the screen.  You would need to use AppleScript to do this.
    How are you trying to move the screen to the center? Any, why does this fail you?
    Robert

  • I am outside the US, how do I sell my book now?

    Hi There,
    I am wanting to sell my book on the iBookStore, I am outside the US (I am in the United Kingdom) and it is saying to have a 'Paid Book Account' I need a valid US Tax ID, How do I sell it now?
    Thanks
    Justin

    Have you opened System Preferences>Date & Time>Time Zone?
    Ciao.

  • When I create a shortcut to a web page from FireFox to the desktop, how can I force Firefox to open from it when I.E. is default and has to stay that way?

    I have a customer that likes to use Firefox browser and does for all they can. Unfortunately they have to also us I.E. with some of their business companies so their browser is set to I.E. by default and must stay that way. Tried changing default for brevity we will just say opened to many other problems. SO, is there a way to create a short cut to the desktop from Firefox and force that shortcut to open with Firefox and not with the default browser IE?
    Thanks,
    Mark

    Hello,
    You can create a new Firefox shortcut on the desktop and add the website address after Firefox. For example:
    Under the shortcut tab, the target could read:
    * "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "www.google.ca"

  • A window has popped up saying, "Want more options? Right-click the app" how do I get rid of this. It won't let me exit it. Is it a virus?

    A window is popping up everytime I open firefox. It says "Want more options? Right click the app" It will not let me close it and won't let me continue on firefox until I give it an answer

    You can start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Belle is a disaster for the E6: how to move on?

    Many and perhaps most who upgraded to Belle did so because the phone prompted them to perform updates. It is considered to be the responsible thing to do. As with PC's; don't skip updates, it may harm your computer or data.
    There was never any warning displayed as to the impact of the upgrade. For example a reduction in available screen, reduced usefulness or widgets or reduced function of the D-pad, were never mentioned. That was negligent. A backup was made during the upgrade process - giving the false impression that the previous version could be restored. That was misleading.
    Nobody could imagine, unless they were regularly checking news and details on developments at Nokia, that their E6 would emerge from the process horrendously defaced and only half functional. Many E6 users use the phone for work and don't follow trends and developments, and can't be expected to do that. Had they been properly informed, they would not have upgraded. They have the right to get back the product they originally bought and used and the assurance that this will not happen again.
    Belle has a ridiculous UI for a business phone, and much reduced functionality compared to Anna. Belle is a disaster specifically for the E6 because the screen is way too small for all the unnecessary eye candy (monstrous widgets) and Belle lacks important functions that Anna had.
    If anyone from Nokia reads this, please respond. Complaining customers are still customers. Complaining customers are more useful than the ones that walk away in silent anger, because you can learn from them.
    As to how to move on: Getting rid of the E6 and trying to forget about it is one thing, but does anyone consider some form of legal action? After all, when you buy something that has properties A, B, and C, and 6 months later the manufacturer single-handedly decides that the product now has properties C, D and E, to all intents and purposes the product is now defective because it lacks properties A and B.
    For example, if the product were a washing machine ("New sleeker user interface, you can now start it by swiping the door, and the water temperature control is gone, it is now 60 Celcius always for everything because 95% of users find that easy"), and no matter what smallprint there is in the warranty, it would be utterly unacceptable.
    Current N900 and former E6 user regretting Belle upgrade
    Devices owned: 2110, 2110i, Cellular Data Card, 8110, 7110, 6210, 6310i, 6100, 9500, 6233, 5140i, 3109c, N900, E6-00

    @slitchfield: on the mentioned page, it is stated that "Improvements in screen real estate, with slimmer top status bar and optional (in some apps) bottom toolbar, meaning that all phones will have a larger useful display area."
    But on the E6 the bottom toolbar decreases available screen size in most apps, most noticeable in Web browser where the full view has gone. The bottom toolbar is not optional, you can't configure it yourself.
    And: "Homescreen widgets will now come in up to five different sizes (1x1, 2x1, 4x1, 2x2, 4x4) and allow a greater degree of interactivity.", but on the E6 they are in only one size, always with large borders and other visual effects.
    So beware of differences between phones, perhaps some aspects of Belle work differently depending on the type of device.
    "Notes now brings up a white (and AMOLED-unfriendly...) editing screen.": that you can change by switching themes, "Dark Solid for Anna" does a good job. It is a shame that the lines of Notes have gone though.
    When switching themes, I found you have to restart the phone, otherwise the theme doesn't get properly loaded in all apps. Stopping/starting apps is not enough. So when experimenting and loading one theme after another, you may end up with disfunctional combinations of black-on-black and white-on-white, but it may not be due to the last theme. Also you may end up with a good combination that isn't around anymore the next time you restart your phone.
    Current N900 and former E6 user regretting Belle upgrade
    Devices owned: 2110, 2110i, Cellular Data Card, 8110, 7110, 6210, 6310i, 6100, 9500, 6233, 5140i, 3109c, N900, E6-00

  • Program downloaded to desktop,how to move?

    When I got my MacBook 2 weeks ago one of the first things I did was download Foxfire. I read on this forum that it was compatible and I used it on my PC for years and really liked it. Well when I downloaded it I didn't have any problems and it runs great. But... it's file is on my desktop. I am able to put an icon in my dock but can't get the file off the desktop. I have looked in the help and read this forum to no avail.
    Thank you for any help or insight you can give me I have really enjoyed learning about this computer.
    K

    Okay here is what I've done. When I did what Mike suggested I succeeded in erasing the whole program. So I went to Safari changed the download prefrences and downloaded the foxfire again to the application folder. But when I start the program it puts the Icon right back on the desktop. I guess that is just where it likes to be. :0) I can eject it but it goes right back when restarted. I appreciate the help but since this really is more a cosmetic problem than anything I'll consider it closed. I just like a clean desktop...
    Thank you, but I will check back just in case

  • I have downloaded a Lowrance XOG update to the desktop.How do I install to the SD card?

    Help !!! Also... how do I get Safari back to full screen ...not sure what I did but it is only at 1/2 screen size. Thanks

    Will repost to iMac Intel....does not seem to be either ext you refer to. File name is "XOG-full_180.command" On the Lowrance website the following instructios are posted for MAC OS X :
    Mac OS X users may need to reapply the execute permissions to the stand-alone installer after it has finished downloading. To reapply the execute permissions, open a Terminal window, and type the following command (this assumes you downloaded the file to your desktop):
    chmod +x desktop/XOG-full_180.command
    I am trying another download as I noticed the following also :
    If your computer experiences problems with the web installer, try using a stand-alone installer. Note: Do not download this installer to your unit - save it to your computer and run the installer to load the necessary files to the unit.Simply choose the appropriate operating system below:
    PC Win98/ME/2000/XP/2003/Vista   |   Mac OS X   |   Linux
    How do I know if Java is working / up to date...should I go to the website and download???? Thanks    Jay

Maybe you are looking for