How can I distinguish a JMenuItem , JPopupMenu and TopLevelMenu?

I used the following methods to get the component who (a menu)gains the focus:
JComponent com = JFrmame.getFocusOwner();
or
MenuSelectionManager menuMgr = MenuSelectionManager.defaultManager();
MenuElement[] menuPath = menuMgr.getSelectedPath();
if(menuPath != 0) {
JComponent comp = Array.get(menuPath, menuPath.length-1); // this is the item with the focus
then I need to use getAction() to get the menuItem's action. But how can I filter JMenuItem and JPopUpMenu from TopLevelMenu (JMenuBar item) ?
Thanks!

The instanceof may provide the simplest solution, since JPopupMenu, JMenuBar and JMenuItem don't have any kind of ancestor relationship with each other.if (comp instanceof JPopupMenu) {
    // Popup
} else if (comp instanceof JMenuItem) {
    // Item
} else if (comp instanceof JMenuBar) {
    // Bar
} else ...?Hope this helps,
-Troy

Similar Messages

  • How can I distinguish between the first and the rest in Smartforms??

    I have made an Invoice in Smartform. I have to take three copies of that. In the first copy it will be printed "ORGINAL INVOICE" and in the next copies it will print "Duplicate copy".  How can I distinguish between the first and the rest in Smartforms??
    Regards,
    Subhasish

    >
    Subhasish Ganguly wrote:
    > I have made an Invoice in Smartform. I have to take three copies of that. In the first copy it will be printed "ORGINAL INVOICE" and in the next copies it will print "Duplicate copy".  How can I distinguish between the first and the rest in Smartforms??
    Hello Vamshi,
    As per the OP's requirement he has to print 3 copies of the invoice. Which according to my understanding should be printed at the same time ? May be i am wrong in interpreting this.
    You must be knowing you can control the print params of the SmartForms in CONTROL_PARAMETERS where you set the NO_DIALOG & in the OUTPUT_OPTIONS pass the number of copies.
    I think the solution you have proposed the "Original Copy" will be printed only once. (Correct me if i am wrong)
    Every time the user prints the invoice again he will be getting a "Duplicate Copy". If this is what the OP wants the logic is perfect
    Cheers,
    SUhas

  • How can we distinguish between post, parked and rejected invoice in SAP

    Hi Guys,
    Is there any way by which we can distinguish post, parked and rejected invoice. I mean to say any field gets updated after doing any of these activity...
    Help from you all will be highly appreciated...
    Thanks in advance,
    Vikash

    Hi,
    If BKPF-Bstat is space then its a normal document and if it is A then its clearing..
    A     Clearing Document
    B     Reset clearing document
    D     Recurring entry document
    M     Sample document
    S     Noted items
    V     Parked document
    W     Parked document with change of document ID
    Z     Parked document which was deleted
    I hope this helps.
    Regards
    Ravinagh Boni

  • How can we distinguish b/c general purpose and top level containers?

    how can we distinguish b/c general purpose and top level containers?plzzz help me out

    May be this will help u out
    http://www.ictp.trieste.it/~manuals/programming/Java/tutorial/uiswing/components/components_pics.html

  • How can I distinguish between a regular iPod and a iPod 4 s?

    How can I distinguish between a regular iPod and a iPod 4 s?

    Hi ARPantoja!
    I have an article here that can help you distinguish different iPod models:
    Identifying iPod models
    http://support.apple.com/kb/HT1353
    Take care, and thanks for visiting the Apple Support Communities.
    -Braden

  • How can I distinguish special characters or signs in Doc through VBA?

    How can I distinguish special characters or signs in Doc through VBA?
    I have a few large documents written in word 2003 format and now I work on them under word 2007.
    Such large documents containing lots of special characters.  I want to change them into Microsoft 3.0 equation form(It is required by the team). I find no way but using function AddOLEObject and  Sendkeys through VBA. Common characters can be added
    to equation by function Sendkeys, but the return value of Asc() or AscW() for "double arrow", "in" , " not greater than " such special characters or signs, to name but a few are the same ,i.e., 40 And I cannot distinguish them.
    I found the link http://msdn.itags.org/word/44333/ may be of use to me, and the title is:
    How to read symbols from a DOC documents! (Microsoft Word)
     the original question is
    Using function "InsertSymbol", I can insert a symbol into a document. But
    how can I read a symbol from a document?
    Using "Characters(i).range.text", I can read a char. But when meeting a
    symbol, the value of "Characters(i).range.text" is always '('.How can I get the CharacterNumber of the symbol.
    And the final answer is :
    Hi chenfeng,
    Word protects symbols from symbol fonts if you insert them from the "Insert
    > Symbol" dialog.
    This is done so they aren't changed when you change the font or style. But
    it also results in Word reporting AscW( ) = 40 on all of them.
    I've posted a macro to "unprotect" them (or to protect them again if you
    want) ... just today again in
    Newsgroups: microsoft.public.word.vba.customization
    Subject: Symbol Characters
    Date: Mon, 3 May 2004 11:00:46 -0700
    Message-ID: <09f401c43138$8f92f900$[email protected]>
    It isn't archived on Google yet, but tomorrow you should be able to simply
    copy the message ID into http://www.google.com/advanced_group_search.
    Regards,
    Klaus
    But the link for the macro in the final answer is missing.
    Can anyone with kindness help me? Thaks a lot.

    Following Cindy Meister's Advice ,I use MathType SDK.
    The sample in MathType SDK in the following may be meaningful,but I do not know how the MTEF for cos^^2Theta, MTEF for sin^^2Theta and MTEF for 1 are generated .
    It looks much complicated,and I searched the docs in MathType SDK to get a explanation.Is there any function to generate them? I want to use this method to change commaon text mathematical signs( in special character table) and  Greek letters and characters
    with subscripts and superscripts to Microsoft 3.0 equation form.
    Can anyone with kindness help me?
    Sub MTEFTextSubstitution()
        Dim MTEFStr1$, MTEFStr2$, MTEFStr3$
        Dim stat
        'MTEF for cos^^2Theta
        MTEFStr1$ = "% MathType!MTEF!2!1!+-" + _
            " % feaaeaart1ev0aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLn" + _
            " % hiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYbItLDharqqtubsr" + _
            " % 4rNCHbGeaGqiVu0Je9sqqrpepC0xbbL8F4rqqrFfpeea0xe9Lq-Jc9" + _
            " % vqaqpepm0xbba9pwe9Q8fs0-yqaqpepae9pg0FirpepeKkFr0xfr-x" + _
            " % fr-xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaci4yaiaac+" + _
            " % gacaGGZbWaaWbaaSqabeaacaaIYaaaaOGaeqiUdehaaa!3B65!"
        'MTEF for sin^^2Theta
        MTEFStr2$ = "% MathType!MTEF!2!1!+-" + _
            " % feaaeaart1ev0aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLn" + _
            " % hiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYbItLDharqqtubsr" + _
            " % 4rNCHbGeaGqiVu0Je9sqqrpepC0xbbL8F4rqqrFfpeea0xe9Lq-Jc9" + _
            " % vqaqpepm0xbba9pwe9Q8fs0-yqaqpepae9pg0FirpepeKkFr0xfr-x" + _
            " % fr-xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaci4CaiaacM" + _
            " % gacaGGUbWaaWbaaSqabeaacaaIYaaaaOGaeqiUdehaaa!3B6A!"
        'MTEF for 1
        MTEFStr3$ = "% MathType!MTEF!2!1!+-" + _
            " % feaaeaart1ev0aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLn" + _
            " % hiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYbItLDharqqtubsr" + _
            " % 4rNCHbGeaGqiVu0Je9sqqrpepC0xbbL8F4rqqrFfpeea0xe9Lq-Jc9" + _
            " % vqaqpepm0xbba9pwe9Q8fs0-yqaqpepae9pg0FirpepeKkFr0xfr-x" + _
            " % fr-xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGcbaGaaGymaaaa!36A4!"
        Selection.Copy
        'Init API, reset transform
    '    If MTUtil.CheckMTDLLVersion = 0 Then Exit Sub
        If Not IsDLLVersionOK() Then Exit Sub
        MTXFormReset
        'first substitution
        stat = MTXFormAddVarSub( _
            mtxfmSUBST_ONE, _
            mtxfmVAR_SUB_PLAIN_TEXT, "<v1>", 0, _
            mtxfmVAR_SUB_MTEF_TEXT, MTEFStr1$, Len(MTEFStr1$), 0)
        If stat <> 0 Then
            MsgBox "1st MTXFormAddVarSub returned: " + Str(stat)
            Exit Sub
        End If
        'second substitution
        stat = MTXFormAddVarSub( _
            mtxfmSUBST_ONE, _
            mtxfmVAR_SUB_PLAIN_TEXT, "<v2>", 0, _
            mtxfmVAR_SUB_MTEF_TEXT, MTEFStr2$, Len(MTEFStr2$), 0)
        If stat <> 0 Then
            MsgBox "2nd MTXFormAddVarSub returned: " + Str(stat)
            Exit Sub
        End If
        'third substitution
        stat = MTXFormAddVarSub( _
            mtxfmSUBST_ONE, _
            mtxfmVAR_SUB_PLAIN_TEXT, "<v3>", 0, _
            mtxfmVAR_SUB_MTEF_TEXT, MTEFStr3$, Len(MTEFStr3$), 0)
        If stat <> 0 Then
            MsgBox "3rd MTXFormAddVarSub returned: " + Str(stat)
            Exit Sub
        End If
        'do the substitution
        stat = TransformGraphicEquation
        If stat <> 0 Then
            MsgBox "TransformGraphicEquation returned: " + Str(stat)
            Exit Sub
        End If
        MTTermAPI
        'Paste new equation
        Selection.Collapse Direction:=wdCollapseEnd
        Selection.PasteSpecial Placement:=wdInLine
    End Sub

  • How can i distinguish between set or tuples from incoming filters in a calculation

    How can i distinguish between set or tuples from incoming filters in a calculation. i am using descendants function with the leaves option to calculate some project revenue cause there is different calcuation method on sub projects the sum on the main project
    should reflect the sum of the sub project with all different methods.
    this works fine until i try to select 2 sub projects at the same time. i am getting the standard currentset dosnt work cause its a set.
    is there i way i can check if its a multiple select or not and handle it a different way

    Hi,
    Check the following link about Multi Select Calculations written by Mosha.
    http://sqlblog.com/blogs/mosha/archive/2007/01/13/multiselect-friendly-mdx-for-calculations-looking-at-current-coordinate.aspx
    Best regards...
    Chandima Lakmal Fonseka

  • My emails do not go - they exit outbox and go to recovered. How can I delete my Icloud account and just use gmail.

    My emails go from outbox into I cloud recovered section. I have gmail too. how can I delete my icloud account and just use gmail? Speed test on wifi good.
    Any ideas please.

    Sign out of iCloud (System Preferences>iCloud)

  • How can I print with the black and white cartridge only?

    I am trying to print using the black and white cartridge only because magenta is out of ink but I'm getting the following error message in HP Photosmart C7200 series print dialog:
    The printer is out of ink.
    The following ink cartridges are empty: Magenta. Replace these ink cartridges to resume printing.
    How can I print with the black and white cartridge only?
    Mac OSX 10.7.3
    HP Photosmart C7280 (7200 series)
    This question was solved.
    View Solution.

    I am absolutely disgusted by this; clearly a scam from HP to make more money by selling extra ink cartridges!!  I will make sure to never buy any products from the shoddy rip off merchants at HP ever again!!
    You should be ashamed!!

  • How can we find the most usage and lowest usage of table in Sql Server by T-SQL

    how can we find the most usage and lowest usage of table in Sql Server by T-SQL
    The table has time stamp column
    StartedOn datetime
    EndedOn datetime

    The Below query has been used , but the textdata column doesnot include the name of the table ServiceLog.
    SELECT
    FROM
    databasename,
    duration
    fn_trace_gettable('F:\Program
    Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\log_148.trc',
    default)
    WHERE
    DATABASENAME='ZTCFUTURE'
    AND TEXTDATA
    IS
    NOT
    NULL
    --AND TEXTDATA LIKE 'SERVICE%'
    order
    by cpu
    desc; 

  • I want to remove the monitor from my 17" Macbook Pro 2008 to use as an external for my Macbook Pro 15" 2012. How can I convert lvds to Thunderbolt and power the monitor?

    I want to remove the monitor from my 17" Macbook Pro 2008 to use as an external for my Macbook Pro 15" 2012. How can I convert lvds to Thunderbolt and power the monitor?

    It's almost impossible.  The new iMacs have a Target Display Mode, but it's built to do that.  Without ripping your screen out, finding an acceptable power supply, frame, and whatever electronics to convert a Thunderbolt signal to the screen, the cost will be much larger than buying a cheaper HiDef monitor that runs with an HDMI to Thunderbolt cable to your MacBook 15.  In fact, you can sell your 17" MBP for a lot of money, unless it's broken or something, buying you a really sweet monitor.
    By the way, I found your answer by searching this forum.  I would suggest using the search function here in the futuere.

  • TS3280 How can i enable both paired bluetooth and ios keyboard input at the same time?

    How can i enable both paired bluetooth and ios keyboard input at the same time?
    This is needed for the app im working on. Need some user input via keypad as well as scanner input via a paired bluetooth scanner.

    You probably should not be using a keyboard bluetooth profile for a scanner, I am not a developer for apple so do not know the location for you to find out the correct profile you should be using for an input device that is not a keyboard. Sorry,
    I am sure if you navigate the apple developer site you will probaly finmd what you're looking for.
    https://developer.apple.com

  • I am unable to update my album art since I commenced using match (and after upgrading to Yosemite).  How can I 'unembed' old cover art and replace?

    I am unable to update my album art on my iMac since I started using Match (and after upgrading to Yosemite 10.10.3).  A message advises that it's not possible to removed old artwork if it's embedded.  How can I 'unembed' old cover art and replace?

    Normally artwork recovered with iTunes is stored as a separate artwork file and iTunes refers to that file to display artwork when you click on a track.  However, if you then copy the file to another player the artwork file is left behind and the track will not display the artwork on the other player.  To get around this it is possible to embed the artwork in the music file itself so it always travels with the file.  Artwork can be embedded by you or files from third party sources may arrive with embedded artwork.  iTunes apparently now won't replace artwork for such files.  You can accomplish this by completely deleting artwork for a file or set of files in Get Info, then getting iTunes to fetch artwork which will then be set as a reference file rather than being embedded.
    I use an old iTunes so unless you are using an ancient iTunes it won't help for me to give you great details.  To erase artwork I simply get info on a series of files and check the box next to the artwork box without adding any artwork and close.  To do it for  single file I Get Info, go to the artwork display tab and click delete.  Here's a Windows reference for a newer iTunes (but the "old Get Info" reference is for early iTunes 12 and no longer works with newer):I cannot delete embedded album artwork in iTunes 12

  • How can I set BPEL server enviorment and create BPEL domain?

    Without use the http console, how can I set BPEL server enviorment and create BPEL domain?
    When I try to use API like below
    import com.oracle.bpel.client.Server;
    Server s = new Server(ServerAuthFactory.authenticate("oracle","localhost"));
    But I always got four exceptions and one warning like below:
    java.io.FileNotFoundException: C:\Workspace\WOSEDISystem\BPEL_Domain_Creation\config\security.properties (The system cannot find the path specified)
    java.io.FileNotFoundException: C:\Workspace\WOSEDISystem\BPEL_Domain_Creation\config\ejb.properties (The system cannot find the path specified)
    Warning: unable to read transaction.interoperability config property
    java.io.FileNotFoundException: C:\Workspace\WOSEDISystem\BPEL_Domain_Creation\config\security.properties (The system cannot find the path specified)
    java.lang.Exception: Failed to create "ejb/collaxa/system/ServerBean" bean; exception reported is: "javax.naming.CommunicationException: Can't find SerialContextProvider
    Is it right to use com.oracle.bpel.client.Server like this, please help me.
    Best regards,
    Vita

    Anyone can help me? Because I need deploy BPEL process on production server, so I need the Java funtion to create domain. Thank you very much if you can tell me the correct method of using com.oracle.bpel.client.Server API.

  • How can i update data in okc_k_items and csi_item_instances tables?

    How can i update data in okc_k_items and csi_item_instances tables?
    by EBS .
    Thanks.

    For csi_item_instances table, you can use the following API:
    CSI_ITEM_INSTANCE_PUB.UPDATE_ITEM_INSTANCE
    For okc_k_items, try using the following API:
    OKC_CONTRACT_ITEM_PUB.UPDATE_CONTRACT_ITEM
    Hope this helps!

Maybe you are looking for

  • Batch job creation for sending email if the invoice is aged

    Positive confirmation: Send system notification to the requestor if: a) An invoice is received and GR is not yet posted in the ECC system. b) An 'aged' invoice and GR is not yet posted in the ECC system. This requirement is for USA only. i.e., we hav

  • RC-50004: Fatal: Error occurred in ApplyAppsTechStack: While Installatling EBS R12 on window server 2003 SP2

    Hi Mr.Hussain, Can you please guide me how to solve this error, i am trying to install oracle EBS  R12.1.1 on windows server 2003, i am following your document, installation of EBS R12.1 in windows server 2003 SP2 i did stage everything going right,

  • The form base xlm can't creat in the File System Repository

    Hi all A document created by  the sap demo news can display in the folder base the cm Repository corrected,but can't in File System Repository. What is the reason? Edited by: joecui on Apr 9, 2010 7:11 AM

  • Equipment partner functions

    Hello all!! Is there a FM to create partners functions for an equipment? Unfortunately it is not possible to create them when I create the equipment with BAPI_EQUI_CREATE. Thanks

  • Accrual Reversal

    Friends, Apart from FBS1 & F.81 any other way to post the Accural and Reversal entreis,because our user feel difficult to use the FBS1 TC For posting the Accural Entry, Please suggest. Thanks & Regards BK