How to keep a border even after right-clicking

I have a JButton around which I would like:
1) a raised border to appear when hovering over the button,
2) a lowered border to appear when left-clicking on the button,
3) no border to appear when releasing or exiting the button, and
4) a raised border to appear when right-clicking on the button and bringing up a popup menu.
I created a MouseListener to achieve effects 1) through 3) above, but I'm having trouble achieving effect 4).
It appears that showing a popup menu causes my MouseListener's mouseExited() method to be fired. This method, though, is currently only responsible for achieving effect 3).
Is there a way to make my mouseExited() method smart enough to implement effect 4) instead of 3) if it realizes it has been invoked as a result of a popup menu display? In other words, is there a way to make a border appear around my button even when the user has opened up a popup menu for that button?
I tried interrogating the value of MouseEvent.isPopupTrigger(), but that always appears to return false in mouseExited() [ it only ever returns true for me in mouseReleased() ].
Any suggestions would be greatly appreciated.
Thanks,
Mike

Jay,
Thanks for your reply. Attached is my updated code that includes the popup listening logic. This logic seems to work, except for the following issues:
1) The button becomes temporarily depressed when right-clicking on it (just as you stated).
2) If I right click on a Button A to display its popup menu and then move my mouse over to another Button B, Button B becomes raised even though Button A's popup menu hasn't been dealt with yet.
Regarding issue 1) above, could I test for whether mouse BUTTON_1 or BUTTON_2 was pressed to determine whether the mouse should be depressed, or would this make my logic platform-dependent?
Regarding issue 2) above, is there a way to block other buttons from appearing raised while a popup menu still appears in support of another button? Or is there just a problem in my implementation of the popup (i.e. it doesn't expire)?
Thanks,
Mike
     public class ButtonBorderMouseListener implements MouseListener, PopupMenuListener
          public final Border NO_BORDER = BorderFactory.createEmptyBorder();
          public final Border LOWERED_BEVEL_BORDER = BorderFactory.createLoweredBevelBorder();
          public final Border RAISED_BEVEL_BORDER = BorderFactory.createRaisedBevelBorder();
          private boolean m_buttonPopupIsVisible;
          public ButtonBorderMouseListener()
               super();
          public synchronized boolean buttonPopupIsVisible()
               return m_buttonPopupIsVisible;
          public synchronized void setButtonPopupIsVisible(boolean isVisible_)
               m_buttonPopupIsVisible = isVisible_;
          /* (non-Javadoc)
           * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
          public void mouseClicked(MouseEvent e)
               System.out.println("Mouse clicked");
               System.out.println("Is a popup trigger == " + e.isPopupTrigger());
               JButton sourceBtn = (JButton) e.getComponent();
               Border borderToApply = ((buttonPopupIsVisible()) ? RAISED_BEVEL_BORDER : LOWERED_BEVEL_BORDER);
               System.out.println("borderToApply == " + ((borderToApply == RAISED_BEVEL_BORDER) ? "RAISED" : "LOWERED"));
               sourceBtn.setBorder(borderToApply);
          /* (non-Javadoc)
           * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
          public void mouseEntered(MouseEvent e)
               System.out.println("Mouse entered");
               JButton sourceBtn = (JButton) e.getComponent();
               sourceBtn.setBorder(RAISED_BEVEL_BORDER);
               System.out.println("borderToApply == RAISED");
          /* (non-Javadoc)
           * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
          public void mouseExited(MouseEvent e)
               System.out.println("Mouse exited");
               System.out.println("Is a popup trigger == " + e.isPopupTrigger());
               JButton sourceBtn = (JButton) e.getComponent();
               Border borderToApply = ((buttonPopupIsVisible()) ? RAISED_BEVEL_BORDER : NO_BORDER);
               System.out.println("borderToApply == " + ((borderToApply == RAISED_BEVEL_BORDER) ? "RAISED" : "NONE"));
               sourceBtn.setBorder(borderToApply);
          /* (non-Javadoc)
           * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
          public void mousePressed(MouseEvent e)
               System.out.println("Mouse pressed");
               System.out.println("Is a popup trigger == " + e.isPopupTrigger());
               JButton sourceBtn = (JButton) e.getComponent();
               Border borderToApply = ((e.isPopupTrigger()) ? RAISED_BEVEL_BORDER : LOWERED_BEVEL_BORDER);
               System.out.println("borderToApply == " + ((borderToApply == RAISED_BEVEL_BORDER) ? "RAISED" : "LOWERED"));
               sourceBtn.setBorder(borderToApply);
          /* (non-Javadoc)
           * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
          public void mouseReleased(MouseEvent e)
               System.out.println("Mouse released");
               System.out.println("Is a popup trigger == " + e.isPopupTrigger());
               JButton sourceBtn = (JButton) e.getComponent();
               Border borderToApply = ((e.isPopupTrigger()) ? RAISED_BEVEL_BORDER : NO_BORDER);
               System.out.println("borderToApply == " + ((borderToApply == RAISED_BEVEL_BORDER) ? "RAISED" : "NONE"));
               sourceBtn.setBorder(borderToApply);
          /* (non-Javadoc)
           * @see javax.swing.event.PopupMenuListener#popupMenuCanceled(javax.swing.event.PopupMenuEvent)
          public void popupMenuCanceled(PopupMenuEvent e)
               System.out.println("Popup menu cancelled");
          /* (non-Javadoc)
           * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent)
          public void popupMenuWillBecomeInvisible(PopupMenuEvent e)
               System.out.println("Popup menu will become invisible");
               setButtonPopupIsVisible(false);
               JPopupMenu popupMenu = (JPopupMenu) e.getSource();
               JButton sourceBtn = (JButton) popupMenu.getInvoker();
               System.out.println("borderToApply == NONE");
               sourceBtn.setBorder(NO_BORDER);    
          /* (non-Javadoc)
           * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent)
          public void popupMenuWillBecomeVisible(PopupMenuEvent e)
               System.out.println("Popup menu will become visible");
                setButtonPopupIsVisible(true);
     }

Similar Messages

  • How can I OPEN files I just downloaded? They're on the DOWNLOADS screen of Firefox but I can't open them even after double-clicking? And they're not on the FOLDERS as well. I tried RIGHT-CLICK and the "open dowloading folder" or something does not work! P

    How can I OPEN files I just downloaded? They're on the DOWNLOADS screen of Firefox but I can't open them even after double-clicking? And they're not on the FOLDERS as well. Even the right-click is not working ... the "open containing folder" does not work.
    == This happened ==
    Not sure how often
    == ALWAYS! ==
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)

    Open Containing Folders is never active.

  • InDesign keeps shutting down, even after reinstall. I want to know how to get technical support

    InDesign keeps shutting down, even after reinstall. I want to know how to get technical support so I can get this fix.

    I feel your pain Robert. I do believe VZW and Apple knew all along the I6 Plus would not be available on 19 Sep and that it was a way to bolster new contracts, renewed contracts and apple sales stats. It's unfortunate the company wasn't more clairvoyant, most of us would have still pre-ordered but been a little less frustrated.

  • TS1368 I'm a PC user with an itunes account for several years. I updated my itunes and now it wont open and shows me 'missing file MSVCR80.dll,and error 7(Window error 126)' keep coming up even after re-installing itunes . What should i do?

    I'm a PC user with an itunes account for several years. I updated my itunes and now it wont open and shows me 'missing file MSVCR80.dll,and error 7(Window error 126)' keep coming up even after re-installing itunes . What should i do?

    Click here and follow the instructions.
    (98897)

  • I am trying to access a webpage but it keeps saying I need a client certificate. Even after I click 'continue', I still cannot access the webpage.

    I am trying to access a webpage but it keeps saying I need a client certificate. Even after I click 'continue', I still cannot access the webpage.

    https://etivity.sul.com.au/
    It's to access my work rosters.

  • CC keeps prompting me to upgrade to a new version, even after I click "update"

    CC keeps prompting me to upgrade to a new version, even after I click "update"

    Stevekimplatt please try creating a new administrator account and apply the update there to see if you experience the same behavior.  If so then it is likely the permissions under your current User account have become compromised.  Also which operating system are you using?

  • HT2521 A pop up window in my safari is not closing. Even after several clicks on OK it keeps popping up. And the open window is not allowing me to use the Safari nor is it allowing to restart/Shutdown the Mac. Please help me rectify this error.

    A pop up window on my Safari does not close even after several clicks on OK... this window keeps popping up and is not allowing using the safari nor is it alowing to close the browser. The open Safari is also not allowing to restart or shutdown the notebook. Please help me rectify the problem.

    Force Quit .
    Press command + option + esc keys together at the same time.    Wait.
    When Force Quit window appears, select  Safari, if not already.
    Press Force Quit button at the bottom of the window.      Wait.
    Application will quit.
    If this does not help, press the power button for 7 or more seconds.
    Computer will shut down.
    Restart.
    Hold the shift key down and launch Safari.
    Best.

  • My ipad2 keep on freezing even after restoration and upgrade to software version5.what do i do?

    my ipad2 keep on freezing even after restoration and upgrade to ios5. what do i do?

    Simon...
    If you restored from a backup, the backup may be corrupted.
    Try Restoring as a new device

  • How do I stop redirects even after selecting the advanced panel

    How do I stop redirects even after selecting the advanced panel to warn or not to redirect to another web site?

    Go to Edit/Preferences. You'll see the checkbox option to play after render there.
    Unfortunately, render applies only to the timeline. There is no way to render clips before you add them to a timeline -- except converting them to DV-AVIs before you bring them into your project.

  • My AE just keep blinking orange even after factory reset. Does this means the thing is pass its useful life,

    My AE just keep blinking orange even after several resets. Ths thing is about 4 years old. Is it pass its usefullife?

    Actually, a flashing amber (blinking orange) status light is normal for just after performing a reset. It just indicates that any of the several potential conditions may require your attention:
    The base station has not yet been configured because it is new, or the reset switch has been set.
    You have selected a security configuration that is not recommended.
    One of several other conditions, such as a disconnected Ethernet cable or invalid IP address has been detected.
    (ref: http://docs.info.apple.com/article.html?artnum=305101)
    If you run the AirPort Utility, it will show an amber circle on the summary page next to the area(s) causing the problem. Click on this amber circle and it should provide an explanation.

  • Adobe digital editions will not finish downloading ebook  even after double clicking on hard drive .

    ADE will not download and open the ebook automatially. After locating the .ascm (ebook) file on the hard drive and double clicking on that, it still will not open in ADE.

    I did all that and after I close the ADE and double click on the file, ADE opens right up and it looks like it is downloading (very fast), but nothing shows up in the ADE.
    How do I only get emails from you and not all the other people on the discussion?
    Date: Fri, 23 Dec 2011 15:48:24 -0700
    From: [email protected]
    To: [email protected]
    Subject: Adobe digital editions will not finish downloading ebook  even after double clicking on hard drive .
        Re: Adobe digital editions will not finish downloading ebook  even after double clicking on hard drive .
        created by Jeff A Wright in Adobe Digital Editions - View the full discussion
    Right click on the ACSM file or option click and go to Open With and select Other.  You can then navigate to your Adobe Digital Editions and set the file to open with that. I would then recommend closing Digital Editions, if you have it open, and try double clicking the file.  If Adobe Digital Editions opens then the file association is still correct.  If you continue to have difficulties then I would recommend contacting the vendor you obtained the e-book from.
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4101791#4101791
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4101791#4101791. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Adobe Digital Editions by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How to make a category highlighted after it clicked

    Hi there! Just want to know how to make a category highlighted after user click on it, so he will able to track on which category he is currently on?
    I've already created 3 categories (links) through creating library elements, I already have the hover effect  I made through CSS external stylesheet, everything works, but the category is not highlighted when I browse within it.
    Here is my HTML code of these 3 links:
    <td bgcolor="#663300"><!-- #BeginLibraryItem "/Library/Top_links.lbi" -->
    <div align="right" class="link"><a href="index.html">Home</a>     <a href="Accessories.html">Accessories</a>    <a href="Contact Us.html">Contact Us</a>    </div>
    <!-- #EndLibraryItem --></td>
    And here is my CSS code for these links:
    .link, .link a:link, .link a:visited, .link a:active {
        font-family: "Times New Roman", Times, serif;
        font-size: 18px;
        font-weight: normal;
        color: #FFFF33;
        text-decoration: none;
        padding: 5px;
        #home: color:#00FFFF;
    .link a:hover {
        font-family: "Times New Roman", Times, serif;
        font-size: 18px;
        font-weight: normal;
        color:#FF0000;
        text-decoration: none;
    So how to make the active link highlighted when browsing within it??
    Thank you

    My pages are offline in developing stage, can't give you an URL.
    Here is my HTML code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>untitled</title>
    <link href="css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    </style>
    </head>
    <body class="home">
    <table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
    <td bgcolor="#663709"><!-- #BeginLibraryItem "/Library/Top_links.lbi" -->
    <div align="right" class="link"><a class="home" href="index.html">Home</a>    <a href="Accessories.html">Accessories</a>    <a href="Contact Us.html">Contact Us</a>    </div>
    <!-- #EndLibraryItem --></td>
      </tr>
    And here is my CSS:
    body {
        background-image: none;
        background-color: #2d2625;
    body,td,th {
    .link, .link a:link, .link a:visited, .link a:active {
        font-family: "Times New Roman", Times, serif;
        font-size: 18px;
        font-weight: normal;
        color: #FFFF33;
        text-decoration: none;
        padding: 5px;
        #home: color:#00FFFF;
    .link a:hover {
        font-family: "Times New Roman", Times, serif;
        font-size: 18px;
        font-weight: normal;
        color:#FF0000;
        text-decoration: none;
    What should I modify?

  • Adobe Acrobat 9 pro's windows installer appearing after right click on any file or application

    I accidentally deleted the acrobat 9.0 manually from the program files. The acrobat doesn't work... There is also a nuisance. The windows installer for the Adobe acrobat keep on appearing when i right click a file or application. I have to cancel it. If i wait for it to load, it will say that the feature you are trying to use is on a network resource that is unavailable. Click Ok to try again or enter an alternate path to a folder containing the installer package "AcroPro.msi" in the box below. if i click ok, it will show an error- the path"..." cannot be found. Verify that you have access to this location and try again or try to find the installer package "AcroPro.msi" in a folder from which you can install the product Adobe Acrobat 9 pro ... It will also cause the computer to be very lag. I am seeking assistance. Please help.

    This happens when I right click on ANYTHING at all, I can even just right-click on the desktop and that install window comes on!
    The program itself opens fine separately. I 'll be honest, I haven't used it much as I am just learning all the programs, so if it is actually working correctly I don't know. I do know that I tried to used the "covert to pdf" button while on Internet Explorer and it would not work. Don't know if the problem is related or not...
    I have that idiotic UAC off - it drove me crazy...

  • After right-clicking the Firefox Icon, a window pops up with one of the titles being "Frequent." Web sites are always being added to this section that I do NOT want. Is there a way to control the number of listings under "Frequent?"

    After right clicking the Firefox Icon, a window pops up above the icon with three sections in it. Two are titled, they are "Frequent" and "Tasks."
    The "Frequent" section each time I see it, has added previous sites that I have visited. This list then has lots of duplicates in it. I do not need that, and would like to keep this listing a a favored few.
    Is there a way to stop having superfluous web-sites added to the "Frequent" list ??
    Thanks!

    After right clicking the Firefox Icon, a window pops up above the icon with three sections in it. Two are titled, they are "Frequent" and "Tasks."
    The "Frequent" section each time I see it, has added previous sites that I have visited. This list then has lots of duplicates in it. I do not need that, and would like to keep this listing a a favored few.
    Is there a way to stop having superfluous web-sites added to the "Frequent" list ??
    Thanks!

  • How to view page info other then right click mathod

    how to view page info other then right click mathod

    I'm not sure exactly what you are after but if I remember correctly Fx3 Tools menu has "Page Info" with information the same, or at least similar, to that in '''the-edmeister''''s method.

Maybe you are looking for

  • Indesign CS3 crashing consistantly

    CS3 latest patches, on a 10.5.6 G5 (dual 2ghz) Machine, also fully patched with 2gb of Ram. Likes to crash at start up, and randomly several hours into work. Have run disk repairs and permissions to no end, as well as deleted the prefs file for indes

  • Import and Export - Reg

    Dear All I have exported 20 tables from DB1 to import into another database, say DB2. While importing to DB2, some problem occurs and only 16 tables have been imported. For importing rest of 17,18,19,20 tables. How to import? can we start from 17th t

  • Material Document Output Message

    Hi I cutomize the Mat.Doc Output Message WE01 to ZE01. In OMJ3 I already removed the WE01 for the new plant. However still in the Plant#2000 material document picks up both message Where else i should remove ? Thanks MM

  • Logo in Print Out

    Dear All I copied Company Logo in PLD through Picture field and take print out of that document, it printed fine. But, when I print same document from different PC with another user, logo is not printing. I tried it by pasting the logo in 'B1_Shr' fo

  • Default shell login not taking effect.

    Hello all. MBP running 10.5.1 as a portable user on a 10.5.1 Server fresh build. A user's default shell login was originally set to /bin/bash. I then changed it to "none" and now can not change it back to "/bin/bash" or any other shell. Even when I c