Listen for JTabbedPane scroll events

I want to execute a method each time the op scrolls through the tabs in a JTabbedPane in "SCROLL_TAB_LAYOUT". I have tried implementing ChangeListener, propertychangelistener and componentlistener but none of them seem to notify me when the op scrolls through tabs?
Thanks in adavce
Calypso

Thanks Camickr, sorry for the late reply below is working solution
These are my custom actions which extends wrappedAction
  class ScrollRight extends WrappedAction {
        public ScrollRight(JComponent component, KeyStroke keyStroke) {
            super(component, keyStroke);
        public void actionPerformed(ActionEvent e) {
            this.invokeOriginalAction(e);
            System.out.println("\nScrolling Right");
  class ScrollLeft extends WrappedAction {
        public ScrollLeft(JComponent component, KeyStroke keyStroke) {
            super(component, keyStroke);
        public void actionPerformed(ActionEvent e) {
            this.invokeOriginalAction(e);
            System.out.println("\nScrolling Left");
  }This code was added to my constructor
      KeyStroke right = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.CTRL_MASK);
      KeyStroke left = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.CTRL_MASK);
      InputMap im = tabbedPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
      im.put(right, "scrollTabsForwardAction");
      im.put(left, "scrollTabsBackwardAction");
      ScrollLeft sl =   new ScrollLeft(tabbedPane,left);
      tabbedPane.getActionMap().put(sl.getValue(Action.NAME),sl);
      ScrollRight sr =   new ScrollRight(tabbedPane,right);
      tabbedPane.getActionMap().put(sr.getValue(Action.NAME),sr);Thanks again
Calypso

Similar Messages

  • Listener for JTabbedPane. Which to choose?

    Hello,
    I have written an application using JTabbedPane
    which displays 7 tab values.
    I would like to use some sort of Action Listener for each of the tabs.
    ie when a particular tab is clicked,some action takes place.
    Which actionListener shud I use that will perform the concerned action
    on each tab chosen?
    tabbedPane2.addTab("Proxy A",null,null, "Proxy");
    tabbedPane2.add(?????) // Action Listener
    Can anybody please help.

    I have a list of proxyNames which are stored in a Vector.
    These proxy names are then displayed as Tabs accordingly.
    For every tab there is a specific action to be performed.
    I want to write a single class for handling all events.
    What I have is this:
    while(eNum.hasMoreElements()){
    Object proxyName = eNum.nextElement();
    tabbedPane.addTab(proxyName.toString(), null, null, "Proxy");
    tabbedPane.addChangeListener(itemHandler);
    panel4.add(tabbedPane2);
    class ItemHandler implements ChangeListener{
    public void stateChanged(ChangeEvent e){
    for(int i=0; i < v.size(); i++){     
    // Perform action on choosing the concerned tab...
    How do I have a single event listener?

  • Listening for bubble-clicked event on trayicon

    i'm trying to listen to mouse clicks on balloon messages that are displayed when you call TrayIcon#displayMessage.
    i added an action listener (TrayIcon#addActionListener), which gets called, but it also gets called when you double-click
    on the tray icon itself, so i want to differentiate between clicking on a balloon message and double-clicking on the tray icon.
    its basically the same question as in two previous threads, but one of the administrators (DarrylBurke) said i needed to create a new thread.
    http://forums.sun.com/thread.jspa?threadID=5284529&tstart=0
    http://forums.sun.com/thread.jspa?threadID=5403857&tstart=0
    any ideas appreciated.

    a code sample doesn't help when the functionality of a balloon action listener doesn't exist.
    anyhow, it looks like the original jdesktop project had the concept of adding a balloon listener:
    http://download.java.net/javadesktop/swinglabs/releases/0.8/docs/api/org/jdesktop/jdic/tray/TrayIcon.html
    specifically method TrayIcon#addBalloonActionListener, which lets one listen for interaction with a balloon message.
    looks like that functionality was lost/not added to the java.awt version of the system tray class.

  • How to make component listen for a specific event of another component

    for example, i have several buttons and want them listen for a TreeSelectionEvent... in case anything selected they become active
    i don't want a JTree component activate these buttons...

    here's an overkill,
    import java.util.*;
    abstract class DoWhatever {
        public static Hashtable ht = null;
        public static Object DoWhat( String s, Object obj ) {
         if( null == ht ) {
             ht = new Hashtable();
             ht.put( ThisDoWhatever.NAME, new ThisDoWhatever() );
             ht.put( ThatDoWhatever.NAME, new ThatDoWhatever() );        
         return ( (DoWhatever) ht.get( s ) ).doWhatever( obj );
        public abstract Object doWhatever( Object obj );
    class ThisDoWhatever extends DoWhatever {
        public final static String NAME = "this";
        public Object doWhatever( Object obj ) {
         System.out.println( NAME );
         return null;
    class ThatDoWhatever extends DoWhatever {
        public final static String NAME = "that";
        public Object doWhatever( Object obj ) {
         System.out.println( NAME );
         return null;
    public class DoThisOrThat {
        public static void main( String[] args ) {
         DoWhatever.DoWhat( args[ 0 ], null );
    }

  • Air for iOS 7 App  - Listen for wireless Keyboard events

    Greetings i've been reviewing this older posting relating to the same problem that I have, but cannot surmise the solution from the thread. Could someone help point me in the right direction?
    https://forums.adobe.com/message/5618417
    I've built a flash ios app that relies on the input from 5 keys to function. I'm using Flash CS6 and AIR 13.0.0.111 for iOS. The app wont recognize the input from my bluetooth keyboard though.
    This code works until loaded onto the iPhone:
    stage.addEventListener(KeyboardEvent.KEY_DOWN, ScrollDown);
    function ScrollDown(e:KeyboardEvent):void{
    if (e.keyCode == 83){
    I guess in need to use a event.CHANGE listener but I can't find any similar tutorials to follow.
    Any help would be greatly appreciated.

    I don't know how wireless keyboard work for iDevices...
    Try to add StageText, tap on it and try to edit text using your keyboard. Could StageText hook keyboard input?

  • Make child node listen for parent's event

    Is it possible?and how?

    parent.addEventListener("someEvent",functionInChildComponet);
    or parentApplication, or parentDocument, or
    Application.application...
    Tracy

  • Listening for click event

    I am curious, how can you have a child mxml page listen for
    an event from the parent?
    Let's say you have a button, call it 'btn1' on page1.mxml and
    you want to listen for the click event on page2.mxml. So far this
    is what I have:
    page1.mxml:
    <mx:Button id="btn1" />
    page2.mxml:
    <mx:Script>
    <![CDATA[
    private function btnListener(e:MouseEvent){
    Application.application.btn.addEventListener(MouseEvent.CLICK,
    setState(1));
    ]]>
    </mx:Script>

    "spacehog" <[email protected]> wrote in
    message
    news:glljts$g04$[email protected]..
    >I am curious, how can you have a child mxml page listen
    for an event from
    >the
    > parent?
    >
    > Let's say you have a button, call it 'btn1' on
    page1.mxml and you want to
    > listen for the click event on page2.mxml. So far this is
    what I have:
    >
    > page1.mxml:
    >
    > <mx:Button id="btn1" />
    >
    > page2.mxml:
    >
    > <mx:Script>
    > <![CDATA[
    >
    >
    > private function btnListener(e:MouseEvent){
    >
    Application.application.btn.addEventListener(MouseEvent.CLICK,
    > setState(1));
    > }
    > ]]>
    > </mx:Script>
    Check out Q3:
    http://www.magnoliamultimedia.com/flex_examples/Amys_Flex_FAQ.pdf

  • Handling a table scroll event

    Hi experts,
    I have a table with several columns. In one column there is a small image thumbnail. After the content (JSONModel) has rendered in the table, a javascript is triggered, which searches for the thumbnails and generates on mouseover bigger preview of that image. However, if I scroll down the table, then the preview is not generated and I would like to re-run that script again. Therefore I would like to handle a table scroll event.
    How could a listener to the scroll event of a sapui5 table be handeled?
    Regards
    Stefan

    HI Stefan
    Here is an example. But it is not officially supported.
    Example
    -D

  • Problem listening for a customevent question

    I'm new to WLP and trying to setup a portlet to listen for a custom event.
    I'm using WLP 10.3.2 with two portlets on a page. Portlet 'A' fires a custom event when it is maximized. I verified the event is getting fired. Portlet 'B' is listening for my 'TestEvent' and should display a message if it receives the event. However portlet 'B' never receives the event. Portlet 'B' is a JSP portlet. Below is the code used to fire the event from portlet 'A', and the code from the 'B' portlet .portlet file. Can anyone tell me why portlet 'B' does not receive the event?
    thanks
    PORTLET A CODE TO FIRE EVENT:
    public void fireTestEvent(HttpServletRequest request,
                   HttpServletResponse response, Event event) {
              System.out.println("prepairing to fireTestEvent");
              PortletBackingContext context = PortletBackingContext.getPortletBackingContext(request);     
              context.fireCustomEvent("TestEvent", "test message");
              System.out.println("fired TestEvent");          
    PORTLET B CODE FROM .portlet file
    <?xml version="1.0" encoding="UTF-8"?>
    <portal:root xmlns:netuix="http://www.bea.com/servers/netuix/xsd/controls/netuix/1.0.0"
    xmlns:portal="http://www.bea.com/servers/netuix/xsd/portal/support/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/servers/netuix/xsd/portal/support/1.0.0 portal-support-1_0_0.xsd">
    <netuix:portlet backingFile="backing.Listening" definitionLabel="bPortlet" title="Bportlet">
    <netuix:handlePortalEvent event="onMinimize" eventLabel="handlePortalEvent1"
    fromSelfInstanceOnly="false" onlyIfDisplayed="true" sourceDefinitionLabels="aPortlet">
    <netuix:invokeBackingFileMethod method="handlePortalEvent"/>
    </netuix:handlePortalEvent>
    <netuix:handleCustomEvent event="TestEvent" eventLabel="handleCustomEvent1"
    fromSelfInstanceOnly="false" onlyIfDisplayed="true" sourceDefinitionLabels="aPortlet">
    <netuix:invokeBackingFileMethod method="handleTestEvent"/>
    </netuix:handleCustomEvent>
    <netuix:titlebar>
    <netuix:maximize/>
    <netuix:minimize/>
    </netuix:titlebar>
    <netuix:content>
    <netuix:jspContent contentUri="/portlets/bPortlet.jsp"/>
    </netuix:content>
    </netuix:portlet>
    </portal:root>

    I figured out the issue. Portlet B only listens for the event if it is visible. The event gets fired when portlet A is maximized, so portlet B is no longer visible.
    thanks

  • Is there any way to listen for OS-commands like LINUX/UNIX "kill myApp"?

    Hello, world! ;)
    I would like to get help on the following problem:
    Situation:*
    Implementing my first server-daemon I was wondering if there is any way to listen for OS commands/events affecting the application.
    One particular handling I intend to implement is after an OS termination command (like *"kill myDaemon.jar"* on LINUX/UNIX) to shut down the daemon.
    This would be really helpful, because in this way I would not just shut down the daemon brutally but being able to handle an event like this to shutdown the Thread pool, send all connected peers that the server/daemon will be down for a while, close all connections ...
    Need help:*
    Am I completely forgetting something which solves this problem really quick? :D
    Is there any Listener Interface which I can use to achieve this?
    Is maybe the JVM/JRE handling this and running garbage collectors?
    Is there any site/tutorial/... focusing on problems like this?
    Thanks in advance for any help on this subject!
    JAVAnetic

    Thanks, this was indeed very helpful.
    I implemented a shutdownHook and it works like I hoped it would:
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
          @Override public void run() {
            // shut down commands
        }));After typing *"kill process_ID"* in a terminal the shutdownHook is invoked (like mentioned before) and the shut down commands are executed.
    Works fine.
    Am happy. :D

  • PopUpAnchor listening for Scrolling

    I have a PopUpAnchor, and when I scroll I need the position to update. So I'm calling the updatePopUpTransform() method.
    When you use the scrollbar everything is good. However, when you scroll using the wheel, the updatePopUpTransform seems to be off by about 1 scroll. So if I need my PopUpAnchor to be right at the bottom of something on screen, now there is a gap between them. This doesn't happen when you scroll using the scrollbar though. Anyone have any ideas why these 2 are working differently?
    Here's some of my code:
      this.grid.addEventListener( ScrollEvent.SCROLL, myCallBack );
      this.grid.addEventListener( MouseEvent.MOUSE_WHEEL, myCallBack);
    And in my call back:
    this.myPopup.updatePopUpTransform();
    I've even tried having myCallBack just called from a single Event.SCROLL event, and that doesn't work either. Same results.
    Thanks for the help!

    aneuryzma wrote:
    hi,
    I have implemented a client opening a HttpURLConnection to send an image to a servlet.
    I would like to know how should be the code on the server, listening for httpURLconnections... can you give me some tip ?
    Here is the client code... What I need is the server code... I want to save the file to hard disk, when a post is performed.And you want to use a servlet to do that? Then your google keywords are "file upload servlet". I recommend the links which recommend using Apache software in your servlet.

  • Event to listen for when viewport scrollposition change.

    Hi
    When I scroll, I listen to the VALUE_COMMIT event on the verticalScrollbar, but when I then wan't to do some calculations depending on the new position (using localToGlobal), then properties that localToGlobal uses aren't updated properly, on what component should I listen to updateComplete? Because updateComplate doesn't get fired on the viewport. So what actually relayouts?
    Best Regards
    Martin

    Hi
    Thanks for the answer.
    When I scroll it works better than using the valueCommit event, but if I scroll fast enough the calculations still skew.
    So I've decided to use the enterFrame event instead, doing the calculations all the time instead of just doing it when necessary from the idea: If it works performance wise okay in games. I guess it can work here
    Thanks
    Best regards
    Martin

  • Listening for click event on an af:image tag

    Dear All,
    Can anybody help me why my code does not work.
    Use case, using an Image, i wanted to call a managed bean method whenever I clicked the image. So here is what I did, I added a clientlistner
    and wait for the click event. Also a server listener is attached to the image.
    <af:image >
         <af:clientListener type="click" method="handleImageClick"/>
         <af:serverListener type="ImageEvent"
                           method="#{viewScope.MyBean.handleImageEvent}"/>
    </af:image>...and here is my javascript...
    <f:facet name="metaContainer">
         <af:resource type="javascript">
           function handleImageClick(evt)
                var comp = evt.getSource();
                AdfCustomEvent.queue(comp, "ImageEvent",{ fvalue : comp.getSubmittedValue()},false);
                evt.cancel();
         </af:resource>
    </f:facet>..and here is my managed bean method.
    public void handleImageEvent(ClientEvent ce)
    }I jsut dont know why it does not call my managed bean method. Is there any mistake in my code?
    JDEV 11G PS5
    Thanks

    codigoadf wrote:
    the problem is in Javascript. remove "fvalue : comp.getSubmittedValue()" and will work fine.
    AdfCustomEvent.queue(comp, "ImageEvent",{ },false);comp.getSubmittedValue()?? comp is a imageAhhh yeah..I just copy pasted this code from google..
    Thanks for your help...it now works..

  • Listen for Events from anywhere

    Hello!
    I have an application with a rather complicated component hierarchy.
    How can I have it so that I can listen for events from any component in any component, regardless of who is who's child?
    Thank you!

    You need a broadcasting mechanism.
    Many architecture framework offers this facility, but as a quick hack you can try something like
    public class Broadcaster extends EventDispatcher  ( singleton anti pattern   )
    instance
    then just do Broadcaster.instance.addEventListener or removeEventListener. it's a crappy singleton, but at least it does not hold any global state.
    I've also seen people use Application.application to dispatch/listen globally but really don't like it.
    Note : Use weak references or your views will never be eligible for garbage collections.

  • Is it possible to have listener for orcale shut won event ?

    Hi,
    We know that during normal shut down of the oracle database, message is sent to the clients. Is it possible to have listener for that event using JDC ?
    Any suggestion is welcome.
    TIA,
    Sudarson

    This is not something that Verizon would handle or be able to change.  It would be something that Google would have to change in the Android source code, or the OEMs in their device specific versions.  Or you could just look for another app.

Maybe you are looking for

  • Lost Mail from Sent and Inbox mailboxes in 10.3.9 to 10.4.3 uprgrade?

    I upgraded a couple of days ago from 10.3.9 to 10.4.3. I have now noticed that all old Mail messages from before the upgrade are not retrievable-- emails both sent and received. For all messages in this POP account prior to two days ago, I get a mess

  • Error while compiling BerkeleyDB: Command failed for target `util_sig.lo'

    Hi, While trying to compile BerkeleyDB on Solaris 10 x86 ( is there an easier way to get BerkeleyDB running than compiling from source? ) I was confronted with the error message appended. I used Berkeley 4.4.20 and configured by executing PATH=/usr/c

  • Videos from PC to iTunes for Iphone

    I have a PC and i was trying to download a video from you tube and then sync it on itunes in order to have it on my iphone, it didn't work, the problem seems to be when i try to take the video into iTunes, which i can't. Maybe i am doing something wr

  • IE7 no log off with SPNego

    Hi experts, I have implement SPNego module in EP 7.0, now when I want to log off with the link (up on the right) with IE7 it don't work fine. The browser back on the same screen without close the application. Some one can help me? Thanks. Bye.

  • Installing arch on my dad's computer, wireless only

    So I finally convinced my dad to let me install Arch on his comp and wouldnt you know it, its giving me problems. the main issue is that he is wireless only (linksys wireless-g with speedboost) and ive never played with wireless with linux.  ive atte