JTabbedPane - Catching tab selection change

I want to catch each tab selection change in my JTabbedPane.
When I used ChangeListener, my program was unable to correctly
indicate selected tab in some cases, i.e.:
JTabbedPane contains two tabs: 0,1.
Tab 0 was selected.
Tab 0 was deleted.
In this case JTabbedPane selects tab 1, but selected index remains
unchanged and stateChanged is not called. How can I catch this?

This trick is working, but you see, the problem is more
complicated. The problem is that stateChanged() doesn't work
when index remains unchanged. This is also true for insertTab().
Both insertTab() and removeTabAt() (and maybe smth. else) causes this problem.
Maybe, possible solution will be to override some method of
JTabbedPane, responsible for activating a tab like this...?
tabbedPane = new JTabbedPane {
    activateTab(...) {
        super.activateTab(...);
        firePropertyChange(...);
}But what is the methods prototype and can it be overriden
at all??
In the deep sources of swing :) I've found such tricks:
In JTabbedPane.insertTab():accessibleContext.firePropertyChange(
    AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
    null, component);In JTabbedPane.removeTabAt():accessibleContext.firePropertyChange(
    AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
    component, null);I'm almost convinced that this is the point. But!
I've never worked with Accesibility :(
And I couldn't find out what to do having only swing sources.
Need help.

Similar Messages

  • Variants on tabbed selection screen for ALV reports

    Scenario: We use a tabbed selection screen for an ALV report. We create a variant, make a selection field on the second tab mandatory & save it without a value. When we run the report with the saved variant it does not check that the required field on the second tab is populated before it executes.
    Question: How can I code such a check?
    Edited by: Alridge Tom on Jul 4, 2008 3:43 PM

    Hi,
    try inserting this code apropietly in you program. (1 parameter + Initialization + At-selection-screen + 2 forms)
    START HERE
    PARAMETERS: pa_vari TYPE disvariant-variant.
    INITIALIZATION.
      g_repid = sy-repid.
      CLEAR e_variant.
      e_variant-report   = sy-cprog.
      e_variant-username = sy-uname.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = 'A'
        CHANGING
          cs_variant = e_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 0.
        pa_vari = e_variant-variant.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_vari.
      PERFORM alv_variant_f4 CHANGING pa_vari.
    *&      Form  ALV_VARIANT_F4
    FORM alv_variant_f4 CHANGING pa_vari.
      DATA: l_exit(1) TYPE c.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant       = e_variant
          i_tabname_header = 'ANYTHING'
          i_save           = 'A'
        IMPORTING
          e_exit           = l_exit
          es_variant       = e_variant
        EXCEPTIONS
          not_found        = 2.
      IF sy-subrc = 2.
        MESSAGE ID sy-msgid TYPE 'S'  NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        IF l_exit = space.
          pa_vari = e_variant-variant.
        ENDIF.
      ENDIF.
    ENDFORM.                               " ALV_VARIANT_F4
    END
    Hope iy helps!
    Alfonso

  • Table control on Tabbed selection-screen

    Hi All,
    My Requirement is: I have a tabbed selection-screen with 3 tabs.
    On one of the tabs I have to include a Table control.
    Currently I'm displaying Table control as Pop-up . But I want that on the screen itself.
    Please suggest me how to do this.

    Once i have done this. but only table control was there on the screen.
    design a screen and place one table control.
    y will declare one default subscreen in the selection screen tab declaration,
    and
    At selection-screen.
    change the value of the deflaut screen to ur designed screen.
    below is one example
    controls: tab type tableview using screen 201.
    SELECTION-SCREEN BEGIN OF TABBED BLOCK object FOR 50 LINES.
    SELECTION-SCREEN TAB (60) tab_cls USER-COMMAND ut_cls
                          DEFAULT SCREEN 101.
    SELECTION-SCREEN TAB (60) tab_rcp USER-COMMAND ut_rcp
                          DEFAULT SCREEN 200.
    SELECTION-SCREEN END OF BLOCK object.
    SELECTION-SCREEN BEGIN OF SCREEN 0101 AS SUBSCREEN NESTING LEVEL 2.
    parameters: P_lifnr type lfa1-lifnr.
    SELECTION-SCREEN END OF SCREEN 0101.
    SELECTION-SCREEN BEGIN OF SCREEN 0200 AS SUBSCREEN NESTING LEVEL 2.
    parameters: p_ebele type ekko-ebeln.
    SELECTION-SCREEN END OF SCREEN 0200.
    AT SELECTION-SCREEN.
      CASE sy-dynnr.
        WHEN 1000.
          CASE sy-ucomm.
            WHEN 'PUSH1'.
              object-dynnr = 100.
            WHEN 'UT_RCP'.
              object-dynnr = 201.
            WHEN OTHERS.
          ENDCASE.
    here the defualt screen is 200 but for table control purpose i changed it to 201 which has the table control in it.

  • Jdev11 Tab selection and Enable User Customization on Session bug.

    When you have enabled User Customization for duration of session then what ever user changes on a page it remains the same through out the session,
    ie. Disclosed panel boxes, advanced query criteria, visible columns of tables in panel collections etc.
    The problem is that you cant customize which properties to be kept or not :
    ++Fusion Developer's Guide for Oracle ADF & 34.3 Configuring User Customizations:++
    ++Note+: If you've enabled just session persistence, then all attribute values shown in Table 34-1 will be persisted to the session.+
    There is no way to override this either globally or on an instance.
    The bigger problem is that if you have some business logic about these components appearance or behavior you can’t override user settings.
    Is this a bug?
    Shouldn’t business logic methods override user customization settings?
    Will User Customization for duration of session become configurable?
    details :[http://adfbugs.blogspot.com/2009/09/tab-selection-and-enable-user.html]

    Hi,
    Is this a bug?
    Don't think so. I assume your business logic is dependent on the disclosure state, which usually is reset after each navigation off and on to a page. Using change persistence you explicitly allow the user to keep the changes. So your business logic cannot rely on a changed state.
    The proposed enhancement request to prevent components from perisisting changes sound fair. I'll file one.
    But it isn't that you can't override the persisted information for a component. You can use teh ChangeManager API that is exposed on the ADFFacesContext to override persistence information
    http://download.oracle.com/docs/cd/E15051_01/apirefs.1111/e10684/oracle/adf/view/rich/change/ChangeManager.html
    For example, using a change disclosure event:
      boolean isDisclosed = < whatever you like to set >;
      //Record a Change for 'disclosed' attribute
      AttributeComponentChange aa =
      new AttributeComponentChange('disclosed', isDisclosed ? Boolean.TRUE : Boolean.FALSE);
      AdfFacesContext adfContext = AdfFacesContext.getCurrentInstance();
      //set disclosed state to component. Here you override the user choice
      adfContext.getChangeManager().addComponentChange(getFacesContext(), event.getSource(), aa);Frank
    Edited by: Frank Nimphius on Sep 30, 2009 3:20 PM

  • WHEN-TAB-PAGE-CHANGED's navigation for 1 table

    i have 1 table e.g. Employees
    It's fields displayed in tab's pages canvas
    i want to navigate through the keyboard from the Last item in page_1 to the First Item in page_2 and so on...
    they r in the same table i want to make it programatically not distributing items manually...
    Any ideas plz.
    Regards,
    Abdetu...

    _1) If the user Select any tab randamly so i should do the following as in:_
    -- WHEN-TAB-PAGE-CHANGED
    DECLARE
         tp_nm VARCHAR2(30); -- tab's name
    BEGIN
         tp_nm := GET_CANVAS_PROPERTY('TAB_CANVAS', topmost_tab_page);
         IF tp_nm ='INFO_PERSONAL'  THEN GO_ITEM ('HR_EMPLOYEES.ID_NUMBER');  
         ELSIF tp_nm ='QUALIFICATIONS'  THEN GO_ITEM ('QUALIFICATION_ID');
         ELSIF tp_nm ='MILITARY_STATUS'  THEN GO_ITEM ('HR_EMPLOYEES.MARITAL_STATUS_ID');
         ELSE null;
         END IF;
         END;
    So, it should work as you wrote. I don't see any problem in this code.
    2) i want to navigate through the keyboard from the Last item in page_1 to the First Item in page_2 and so on...programatically ...Okay, there are three options...
    1. If you set the order of items in object navigator (which you don't want) then by pressing the enter key on last item of tab page it will move to the second tab's first item.
    2. Create KEY-NEXT-ITEM trigger and use the GO_ITEM() and send on next tab page's first item.
    3. Use the navigable property as i mentioned earlier.
    -Ammad

  • Spark Datagrid Selection change Event

    starting to work with the spark datagrid.
    I want to send off a web service using the values of a row right after they get done editing the row and leave it.
    No more change event that I can see like MX and gridItemEditorSessionSaveHandler kicks on every tab between cells
    if I use event.currentTarget.selectedItem
    Selection Change gives me the new row.
    Selection Changing only kicks with mouse row changes not tabs
    Suggestions?
    I want to register the row with both mouse (on a numeric stepper) and tab(for text fields) events.
    Thanks
    Dan Pride

    Hi Dan,
    Try valueCommit event handler, but I'm not 100% sure that is triggered upon dataProvider data changes.
    Another way is to listen for changes in the dataProvider variable.

  • In PO invoice tab select tax code shown amount column KOMV-KBETR as 100%

    Hi,
    In PO invoice tab select tax code shown amount column KOMV-KBETR as 100% we need as 10% my alculation is correct but showing only 100%
    i have assigned tax rate in j1id as 10% and Ftxp as same tax code as 100% and condition is JM02 as non-deductable.
    in PO condition value is showing as 10% correct value but showing in amount column as 100%
    Please suggest
    Thanks
    Shital

    No reply

  • Help using app_standard.event(when-tab-page-changed')

    Hello ,
    I need to create a form with the following requirements . There is one content canvas which contains a tabbed canvas and on this there are two stacked canvases .
    The problem is that when I compile my form and ftp to oebs , I cannot view the tab pages on the canvas .
    I see only my the fields displayed in the first tab page without the 'tab pages'.
    How do I solve this issue please ?
    My when-page-page-trigger contains the following :
    BEGIN
         APP_STANDARD.EVENT('WHEN-TAB-PAGE-CHANGED');
    if name_in('system.cursor_block') = 'XX_ERROR_MANAGEMENT' then
    if not form_success then
    -- Revert tab to prior value and exit
    set_canvas_property('CAN_INT',topmost_tab_page,name_in('system.tab_previous_page'));
    return;
    end if;
    -- Move to first item on each tab
    if target_canvas_name = 'CAN_INT' then
         SHOW_VIEW('CAN_ONG1');
    go_item('XX_ERROR_MANAGEMENT.INTERFACE_TYPE');
    else
    show_view(target_canvas_name);
    end if;
    END IF;
    END;
    Any help will be much appreciated . Thanks .

    bump

  • How to generate selection change event through code in JTree?

    I am developing an application which downloads the file from other system and adds it into the tree. On selecting any file in the tree I m displaying it's contents. But now i am trying to display the contents of downloaded file as soon as it's download completes. Here i am not getting the way to how to generate the event as the download completes, because i tried that setSelectionPath(TreePath path), but it also don't generates the selection change event. Is there any other way to do so?

    Put null in place of oldLeadSelectionPath. From the API for TreeSelectionEvent:
    protected TreePath     oldLeadSelectionPath:
    leadSelectionPath before the paths changed, may be null.
    I'm at the office and can't try out anything, so please let me know whether that works for you.
    db
    edit Or it may be easier to put all code from your valueChanged (...) override in a new method and invoke that method both from valueChanged (...) and wherever else you need.
    Edited by: Darryl.Burke

  • How to block lead selection change in a tree ?

    Hi Guys,
    <u>Scenario</u>
    I have MasterTree - DetailEditor pair. <i>MasterTree</i> is used to visit some tree-structured data and <i>DetailEditor</i> is used to edit currently selected tree node.
    <u>Requirement</u>
    If currently selected node data is updated through <i>DetailEditor</i> and needs to be saved, than on a subsequent tree selection change the user should be warned about unsaved data.
    <u>Implementation</u>
    In <b>onAction</b> event handler of <i>MasterTree</i> I check whether last selected node data is updated and needs to be saved and if this is the case rollback <i>treeSelection</i> to that node. On the time <b>onAction</b> event handler is called the tree selection is changed from the node that needs save to the newly selected node. In order to rollback <i>treeSelection</i> I need to introduce variable referencing last selected tree node.
    <u>Question</u>
    Is there any other technique to implement above scenario without using additional variable and manually rollback <i>treeSelection</i> ? For example, to plug in WDP framework on validation step just before lead selection is changed.
    Thanks in advance

    Alex,
    Here is a link to the phase model of WD:
    http://help.sap.com/saphelp_nw04/helpdata/en/b8/cd96edb9c8794aa362e6e8b4236a1f/frameset.htm
    There aren't any hooks provided prior to the event handlers being called. As far as I can tell, the way you are handling it is the only way that will work.
    -Cindy

  • How to veto a JComboBox selection change in ItemListener

    I have a JComboBox whose current value is tied to some data cached in my application. I want to be able to examine the selection in an ItemListener attached to the JComboBox, and if the value is different than what I have cached, I want to ask the user if they really want to change because the change will render some other data as no longer valid. If the user wants to abandon the change, then I want to "abandon" or "veto" the selection change and reset it to the old value.
    For instance, if the combo box has values "Foo" and "Bar" in it, and "Foo" is the cached selection, then the user goes and changes the selection to "Bar", I want to prompt them with something like "You have changed the value to Bar. Doing so will render XXX no longer valid. Do you want to continue?" -- if they cancel the change, then leave the selection as "Foo".
    What is the best way to do this within ItemListener's itemStateChanged? Are there better ways to do this besides what I've outlined? I didn't see anything in "Core JFC" book or the JDK documentation that discussed this sort of thing.
    Thanks in advance,
    Eric

    Hi,
    It is a design problem and not realy a language problem... The way I create vetoing design it that a keep the previous selection of the JComboBox... upon action I look if the application can do the new computation...if not...ask the user... if true| run calculations if not set the JComboBox to the previous selection...
    JRG

  • Reacting on selection-changes in a JTable...

    Hello,
    I created an AbstractTableModel which is the basic for my JTable. Now I want to react on changes of the selection in the table. So I implemented a ListSelectionListener and overwrote the valueChanged()-method. But there is no reaction when the selection changes...is there a special trick with this method, or what else could be the reason for my problem ?
    Thanx,
    Findus

    Did you register your listener?
    yourTable().getSelectionModel().addListSelectionListener(yourListener);

  • Project panels tabs randomly change on launch

    I recently started noticing that my project tabs are getting all jumbled up when I reopen projects. Here's an example:
    This is how my tabs look when I close my project:
    ...and here's how they look when I reopen it:
    Notice how the tabs have changed completely – some tabs open at the root level, others in specific folders and some tabs changed their view from list to grid. This has to be a bug since it only started happening about 2 weeks ago. I already put in a bug report with Adobe but until they get around to fixing it, does anyone know how to fix this?

    Sounds like the same issue discussed here: Project panels tabs get reset to root level at project launch!
    You'll find a proposed workaround there.

  • Tabbed selection screen problem.

    Hi expert,
    I need some help in creating my selection screen.
    Right now i'm creating a tabbed selection screen as the code below follows.
    PARAMETERS: p_test AS CHECKBOX USER-COMMAND testrun DEFAULT 'X'.
    SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
    PARAMETERS: p_offkdt TYPE sy-datum MODIF ID thr.
    SELECT-OPTIONS: s_konfe FOR p0002-konfe.
    SELECTION-SCREEN END OF SCREEN 100.
    SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
    SELECTION-SCREEN: BEGIN OF LINE,
                       COMMENT 1(20) text-005 MODIF ID yea
                        FOR FIELD p_lowdt,
                        POSITION POS_LOW.
    PARAMETERS: p_lowdt TYPE begda MODIF ID yea,
                p_updt TYPE endda MODIF ID yea.
    SELECTION-SCREEN: END OF LINE.
    PARAMETERS: p_keydt TYPE dats MODIF ID yea.
    SELECTION-SCREEN END OF SCREEN 200.
    SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
    PARAMETERS: p_lvdat TYPE dats MODIF ID lv.
    SELECTION-SCREEN END OF SCREEN 300.
    SELECTION-SCREEN: BEGIN OF TABBED BLOCK prog_selection FOR 4 LINES,
                      TAB (20) button1 USER-COMMAND push1,
                      TAB (20) button2 USER-COMMAND push2,
                      TAB (20) button3 USER-COMMAND push3,
                      END OF BLOCK prog_selection.
    Now as I'm using tab and subscreen, therefore i need to initialize the subscreen which i wanted to use which i did in the initialization event.
      prog_selection-dynnr = 100.
      prog_selection-activetab = 'PUSH1'.
    With the above code, my default tab would be screen 100 which is the first tab.
    My problem right now is, after i execute the program, and then i press the back button to go back to the selection screen, the default tab 100 is shown again while i wanted to show the last tab which was picked before the program was executed. Please kindly advise how can i solve this problem.
    Many Thanks!
    -Suwardi Nursalim-

    Hi,
    DATA: V_DYNNR TYPE SY-DYNNR VALUE '0100',
               V_ACTIVETAB(4).
    INITIALIZATION.
      MOVE 'PUSH1' TO V_ACTIVETAB.
    AT SELECTION-SCREEN OUTPUT.
      prog_selection-dynnr = V_DYNNR.
      prog_selection-activetab = V_ACTIVETAB.
    When the user clicks each tab of the tab strip.*
    CASE SY-UCOMM.
       WHEN 'PUSH1'.
            V_ACTIVETAB = 'PUSH1'.
            (rest of your code).
       WHEN 'PUSH2'.
            V_ACTIVETAB = 'PUSH2'.
            (rest of your code).
       WHEN 'PUSH3'.
            V_ACTIVETAB = 'PUSH3'.
            (rest of your code).
    ENDCASE.
    Hope this will help you.
    Regards,
    Smart Varghese

  • How to trap Selection change

    Hi All,
    I need to observer selection change. How do i go about it. In basicpersistinterface the kBPISelectionObserverImpl is bound with the panel. Similarly I want to call a method on selection change and not update some UI, so where do i need to put my ActiveSelectionObserver.
    It can  be just displaying an alert of selection change, but how do we trap it.
    Please contribute your valuable suggestions.
    Thanks in advance.
    Jasmine Shaikh

    You can aggregate your observer to any easily accessed boss that's permanently around. For example kSessionBoss already has 15 observers, kAppBoss has 7 observers. You would use a private IID, though. Invoke AutoAttach from a StartupShutdown service.
    Given that, you're probably wrong architecture-wise by watching the selection without UI involved. There are plenty other notifications, besides there are also different mechanisms to watch the selection from closer on (e.g. SelectionExt). Can you give more details on your intent?
    Dirk

Maybe you are looking for

  • HP Deskjet 3550 cannot print using Airport Extreme via USB connection on Windows 7 64 bits

    Product Name and Number: HP Deskjet 3550 Inkjet Printer Operating System installed: Windows 7 Home Premium 64 bits Error message: None Any changes made to your system before the issue occurred: Setting up HP printer using Airport Utility to add a new

  • Code include from database through servlet into jsp

    Hi all, Im alittle stuck at the moment. I need to store code in a database that will be retrieved and displayed on a webpage. I know how to retrieve the information and display it if it is just normal data. The data in the database will be html along

  • After inserting into one field using LOV,  how to populate other fields ?

    Hi, I have a BLOCK based on a table (ex:EMP) And I have a LOV on the field(item): EMPNO. When I select one EMPNO from the LOV (when the field:EMPNO is populated with an emp number), the other fields should be populated Can some body let me know, whic

  • How do I make trash not do a "Secure Empty Trash"?

    Here is what's happening to my Trash whenever I move a file to it for deletion. Ever since I changed the Trash settings to "Secure Empty Trash", and I securely empty the trash when it only have 1 or 2 files in it, it comes up saying there's like 20.

  • GW 8 and Excel 2007 integration

    I am missing something and cannot get this combination to work with the result that makes my users happy. When trying to save a doc to GW, I get the "Select an application" window (with the library drop down at the bottom) instead of the "Select a li