How do you add an ActionLister to a JTabbedPane???

I have an application that utilises a JTabbedPane. All of the tabbed panes that I add to it are declared in separate classes. Added to the main Frame is also a JMenu and a JToolbar. I can detect which pane is enabled when a button is selected using for example,
if(jtpFantasyLeague.getSelectedComponent() == FLI).
What I would like to do however, is enable and disable the relevant menu and toolbar items as each tabbed pane is selected.
The problem is I don't know how to implement it. I started trying ActionListeners with no success, but a book a have talks vaguely about ModelListener and an EventListener???
Any help, or a link to a relevant tutorial would be great.
Also I would like to know, can I monitor which Pane is selected from the main class where the JTAbbedPane is instantiated or do I need to do it separately in each class that I have added as a tabbed pane??
Thanks in advance for any help,
Kris

Have your main class implement ComponentListener to check on show/hide events. If your main class needs to know about these events, there are a few ways I know of to do so:
a) Inside your main class: FLI.addComponentListener(this);
b) If the panes themselves need to control listener registration, register the main class with a callback. I assume you have a class extending JPanel that represents the contents of each pane. Declare a constructor that requires a reference to an object of type MainClass (or whatever it is). In the constructor, set an attribute (declared as final MainClass owner; in the attribute section) to that arguments value. Whenever the pane needs to add a listener registered to the main class, have it call addComponentListener(owner).
c) This is somewhat sketchy, but...I'll write it anyway. Declare a static variable (active, for example) in MainClass of type MainClass. In your MainClass constructor, code MainClass.active = this;. In your pane's code, instead of addComponentListener(owner), code addComponentListener(MainClass.active).
That oughta do it.
Good Luck, and happy coding!
-Tim
Links:
ComponentListener: http://java.sun.com/j2se/1.4.1/docs/api/java/awt/event/ComponentListener.html

Similar Messages

  • How Do You Add Multiple CSS Rules to Text?

    Hi everyone, I have these css rules in my css styles window they are all assigned to some text in a cell on my page.
    .Def14grey4 <body>
    .def14grey4 a:link <a>
    .def14grey4 a:visited <a>
    .def14grey4 a:hover <a>
    .def14grey4 a:active <a>
    .def14grey4 a:focus <a>
    How do you add (all of) these styles to the text in the first place, I know how to add the first one (.Def14grey4), you select the text in the cell and choose the rule from the drop-down menu in the css panel, but how do you add the other ones to some text as well, so that it can have the same link properties.
    Basically I have some more text elsewhere on the page and want to assign these rules to that as well.
    thanks Gareth

    You would want to change your order as shown here -
    .Def14grey4 <body>
    .def14grey4 a:link <a>
    .def14grey4 a:visited <a>
    .def14grey4 a:hover, .def14grey4 a:focus <a>
    .def14grey4 a:active <a>
    That way, the hover and the focus states are equivalent.
    How do you add (all of) these styles to the text in the first place, I know how to add the first one
    You don't really.  The 4 bottom selectors say -
    "find an element with a class of 'def14grey4', and style any link inside that element this way"
    So, <span class="def14grey4"><a href="whatever.html">Whatever</a></span> would get the pseudo-class styles, as would any of the following -
    <span class="def14grey4"><a href="whatever.html">Whatever</a></span>
    <td class="def14grey4"><a href="whatever.html">Whatever</a></td>
    <p class="def14grey4"><a href="whatever.html">Whatever</a></p>
    <body class="def14grey4"><a href="whatever.html">Whatever</a></body>
    <div class="def14grey4"><a href="whatever.html">Whatever</a></div>
    <strong class="def14grey4"><a href="whatever.html">Whatever</a></strong>
    and so on.  These examples assume that there isn't some other more specific rule that would apply to the same links.  You need to study up on the CSS cascade and specificity....

  • How do you add a google calendar to muse web site, that updates are synced

    how do you add a google calendar to muse web site, that updates are synced?

    You can add Google Calender using iframe which Google provides if you go to calender settings.
    Once you insert this code in Muse page through Object > Insert HTML , the calender will be displayed on page.
    https://support.google.com/calendar/answer/41207?hl=en
    Thanks,
    Sanjit

  • How do you add non-Garage band instruments into a Logic project so that you can hear them on playback?

    How do you add non-Garage band instruments (orchestral instruments) into a Logic Pro (8) project so that you can hear those insrtruments' sounds on playback?  I've tried to understand and follow the Logic Pro 8 User Manual, but the process comes off as so complex and the writing so technical that it does not help but only confuses.
    To be precise - I want to add instruments (orchestral) that are not offered in the current Garage band menu which is offered in the Mixer's channel strip menus for Logic Pro 8.  To be clear, the instruments that are offered are Bass / Drum Kits / Guitars / Mallets / Organs / Pianos and Keyboards / Synth Basics / Synth Leads / Synth Pads.  Most of these that I've tried seem to work and give their characteristic sound when placed in a particular channel and playback is clicked. 
    However - there is one orchestra instrument offered in the standard Logic Pro 8 Mixer channel menu and it's the item labelled "Performance - 000 flute 1 or 001 flute 1."  And it is this instrument that presents a problem. When I click on it and choose it from the menu and enter it as the instrument of choice for a specfic channel / track in my Logic Pro project arrangement, when playing back the music for the overall piece this particular track, the flute, does not playback and produce the notes (Midi events) in the track in the sound of the flute.  Instead, nothing comes out at all.  I can't imagine why this does not work.  Any ideas, anyone? Again, when choosing this instrument for a track and clicking the playback no flute sound is forthcoming.  Why not? I have not tried them all, but when most of the other various types of keyboards, such as an electric piano or an organ, are chosen for a track the playback successfully renders the sound of these instruments.  Why then does playback not produce the sound of the flute when it has clearly been chosen to play and sound the Midi events given it?
    Anyway, the overall, larger issue for me is the inability I have to choose and get non-Garageband instruments (largely orchestral) to play the Midi events given on various tracks. If my guess is correct then technically, orchestral instruments not offered in the standard Logic Pro 8 Garageband Mixer channel menu are referred to as external Midi sampled instruments - still, IMHO the process is not clearly spelled out in the User Manual.  The simple step by step process whereby a non-Garage band instrument, say an orchestral instrument, is placed in a channel replete with Midi event (notes) waiting to be played should be easy, logical and given in a simple to follow format, but is not.
    What with all the talk of routes, busses, auxillary channels, GM devices, GM mixers, audio bins, libraries and audio files this Logic Pro User is confused to the max.  Can someone please help me and, in simple English, describe the step by step process whereby presumably external sampled orchestral instruments can be successfully employed, in any given Logic Pro arrangement project, to render their characteristic sounds upon playback?
    On my two Macs, one a laptop and one a much larger Mac, I have any number of the GSO (Garritan Symphony Orceshtra) and Vienna Symphony Orchestra instrument library samples - and yet - I've yet to figure out how to actually get them INTO a Logic Pro project of any kind!  To put this as a question, even as a humble request, how can I make good use of these orchestral sample libraries in a Logic Pro project?  Can someone steer my to a clear resolution of this issue.  I'd sincerely appreciate it!  Thanks all! 
    DavidBacon

    DavidBacon wrote:
    Anyway, the overall, larger issue for me is the inability I have to choose and get non-Garageband instruments (largely orchestral) to play the Midi events given on various tracks. If my guess is correct then technically, orchestral instruments not offered in the standard Logic Pro 8 Garageband Mixer channel menu are referred to as external Midi sampled instruments - still, IMHO the process is not clearly spelled out in the User Manual.  The simple step by step process whereby a non-Garage band instrument, say an orchestral instrument, is placed in a channel replete with Midi event (notes) waiting to be played should be easy, logical and given in a simple to follow format, but is not.
    What with all the talk of routes, busses, auxillary channels, GM devices, GM mixers, audio bins, libraries and audio files this Logic Pro User is confused to the max.
    David,  you understand that this is professional software and is not necessarily meant to be easy but is in fact designed to give the professional user as many choices as possible, that's why it's in the Pro Apps section. You WILL need to learn about buses, GM Devices, Audio Bins, Libraries...etc..etc if you intend to use Logic.
    That said, you are looking in the wrong place in the channel strip.
      May I offer you advice?
    Go here:
    http://documentation.apple.com/en/logicpro/
    Open "Exploring Logic Pro"  (a short PDF Document). Pay special attention to chapter 3. Also pay special attention to the included graphics of the channel strips.
    I encourage you to read the whole document as it will clear up many things... even though it's a Logic 9 document.
    Post back

  • How do you add an iTunes Gift Card & how is it charged?

    Hey all,
    I currently pay for my iTunes downloads direct from my Debit Card. If I add a gift card to my account will the cost of downloads come from that automatically or do I need to let iTunes know thats what I want?
    Also - how do you add the card? I'm probably being totally stupid but can't seem to find an "add credit here" option.
    Help appreciated

    If you redeem an iTunes gift card, the next purchases you make up to the value of the gift card will be made from it automatically. To add the card, click here; this link will open iTunes.
    (34512)

  • How do you add multiple iTunes to Keynote

    How do you add multiple songs from the iTunes to your Keynote presentation?

    Jer&Renee,
    welcome to Apple Discussions.
    It depends where you want them in your presentation.
    Open the Media inspector and choose a playlist. In the list of entries, mark those you want to add to Keynote (use command-click to mark multiple titles not in one block).
    Then drag the marked titles either on a slide or on the small Audio field (looks like a frame) in Document inspector. When you then hover the cursor at the Audio "frame", you'll see the quick info "Multiple Files". You cannot change the order or remove one of the files, but only all of them.

  • How do you add pictures to your photo book after saving it? Can you re-save it to send to blurb?

    How do you add pictures to your photo book once you have saved it? Moreover, can you save it again and send it to Blurb.

    Go back to Library and drag the extra photos into the book collection.

  • How do you add multiple users to an itunes account

    how do you add multiple users to an itunes account

    First :
    Using an iPhone without a wireless service plan
    Then restore the iPod to factory settings/new iPod on the computer your kids will use:
    iTunes: Restoring iOS software
    If you are using the same computer
    How to use multiple iPods, iPads, or iPhones with one computer

  • How do you add adobe flash player to your mac computer

    How do you add adobe flash player on a mac computer so you can watch youtube and or listen to music?

    Click here and download it.
    (119142)

  • How do you add the ipad device to your itunes account? Please!!

    How do you add the ipad 2 device to your itunes account

    There is no need to add the iPad, just sign into your iTunes account when you need to.

  • How do you add visual video controls to widget video in ibooks author?

    How do you add video controls to video using ibooks author?

    I have the same question as VideoImage. I would like the controls to appear in some of my videos so that the reader can speed them up or slow them down. This would save me having to run them through iMovie at 4X say and saving them that way. As far as I can see, the video fast forward, fast reverse, go to end, go to beginning controls only appear in the Widget inspector. What is their purpose then? 

  • How do you add a video clip to a slide show?

    How do you add a video clip to a slide show using elements 12?

    You can import some very short video clips into Photoshop and make gifs.  I can import short (10 second or so) .mvi video clips I've taken with my point and shoot camera.
    Use File ->Import->Video Frames to Layers
    CS3 doesn't recognize .mvi files until you enter *.* in the box, hit load, then find the file you want.
    After the file has been loaded, go to Windows, and check Animation.
    After the Animation bar loads, go to the right side arrow, check Make Frames from Layers.
    Then Save for Web and Devices, and you've got your gif.
    I find it much easier to use the separate software.

  • How do you add a new thumbnail to a slide show when using in-browser editing?

    how do you add a new thumbnail to a slide show when using in-browser editing?

    At this moment you can’t add pictures to a slideshow. You only can replace them.

  • How do you add a Christmas frame to an image in Elements 10?

    How do you add a Christmas frame to an image in Elements 10?

    In PSE 10, go to Full Edit mode. 
    Open your image.
    Open the Content panel.
    In the first dropdown choose "By Event".
    In the second dropdown choose Christmas.

  • How do you add an application event to the Applications Panel

    How do you add an application event to the Applications Panel.
    My previous post referred to .ashx files, and the problem seems that Firefox, by default, does not recognize a .ashx format being read by Adobe Acrobat.
    Therefore there needs to be a way to add Applications and Events into the Applications Panel under Preferences

    domdp wrote:
    ...I have Theme L selected and I get 10 icons along the left side and bottom....
    ...I am thinking I may be limited to 10 icons....
    Gotcha... But actually its limited to 9 icons in the L theme as the Profiles icon is always present. From that screen hit the Menu key to display the bigger list of icons. Arange them so the first 9 icons are the ones you want to see on the L theme.

Maybe you are looking for

  • Re- or De-Authorization

    In the process of trying to share my laptop and my desktop I changed my local computer name and now my laptop is not authorized and I cannot sync my IPhone. When I tried to use my final authorization to re-authorize it it tells me: "There was an erro

  • Specifying queue name in SOAP sender channel

    Hi   We are on XI 3.0 SP18 - I have a requirement in which a soap webservice exposed out of the XI box - is to be called in an asynchronous mode - the webservice posts - document onto R/3 using an ABAP server proxy. Now, there is also a need to post

  • Linking information between one Delivery Order and many Goods Receipt

    We have a case of a business process we're looking for the solutions base on mySAP ECC 6.0 We deliver to customers by barge, each of DO for one barge. Goods on each delivery barge receipt  directly from many truck, Can you tell me the SAP help to man

  • Password history in IDM7.0

    Hi all, I have a requirement where i need to enable the password history for end user(for reset password and change password also).Can anybody give a solution for me??? Thanks in advance.......

  • MacBook Pro will not connect with Printer

    My MacBook Pro will not connect to my HP Photosmart Printer, both are wireless. Receive a error message