Tab Selection in JTabbedPane

I have a JTabbedPane with 3 Tabs.Each of the Tabs contains a JScrollPane which in turn contain a JTable. When the JTabbedPane is displayed and the third Tab is selected the contents of the second tab are shown. Only when each of the Tabs have been selected do the Tab contents appear correctly.
I have tried everything I can think of to sort this, has anyone got a way of fixing this?

To understand the code I would need to post too much so here is a pseudocode version of what it does:
contentPane.removeAll();
JTabbedPane.removeAll();
JTabbedPane.add(title[0],scrollpane[0]);
JTabbedPane.add(title[1],scrollpane[1]);
JTabbedPane.add(title[2],scrollpane[2]);
contentPane.add(JTabbedPane);
contentPane.setVisible(true);
I have tried to debug the problem and when the the third tab is selected the selected index and component are correct but they aren't displayed correctly.

Similar Messages

  • JTabbedPane tab selection colors

    I'm just wondering if there's an easier way to change the colors of the tabs in a JTabbedPane when moving between tabs?? I've tried the UIManager.put() with no luck.
    public void stateChanged(ChangeEvent event)
         if (tabbedPane.getSelectedIndex() == 0)
              tabbedPane.setBackgroundAt(0, panelColor);
              tabbedPane.setBackgroundAt(1, null);
              tabbedPane.setBackgroundAt(2, null);
         else if (tabbedPane.getSelectedIndex() == 1)
              tabbedPane.setBackgroundAt(0, null);
              tabbedPane.setBackgroundAt(1, panelColor);
              tabbedPane.setBackgroundAt(2, null);
         else if (tabbedPane.getSelectedIndex() == 2)
              tabbedPane.setBackgroundAt(0, null);
              tabbedPane.setBackgroundAt(1, null);
              tabbedPane.setBackgroundAt(2, panelColor);

    Try something like this:
    public void stateChanged(ChangeEvent e)
         for (int i = 0; i < tabbedPane.getTabCount(); i++)
              tabbedPane.setBackgroundAt(i, Color.yellow);
              tabbedPane.setForegroundAt(i, Color.redl);
         int selected = tabbedPane.getSelectedIndex();
         tabbedPane.setBackgroundAt( selected, Color.blue );
         tabbedPane.setForegroundAt( selected, Color.green );
    }Does this code work for you?
    When I try this code the setForegroundAt() method works.
    The setBackgroundAt() method works inside the for loop, but not outside. That is I see tabs with a background of yellow, but the selected tab still shows a background of grey, not blue. Does this happen for you.
    I'm running the Windows LAF on Windows 98 and JDK1.3

  • Listening to changes in tab selection on the JTabbedPane

    How can I to listen to any new selection in another tab of the JTabbedPane?
    supposed that I want the program to do a certain action each time the user select another tab with the mouse - and an action which is accordingly to the new selected index (of the new selected tab)...

    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTabbedPane.html#addChangeListener(javax.swing.event.ChangeListener)

  • 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.

  • 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

  • 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

  • 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

  • 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.

  • Sharing objects between different tabs on a JTabbedPane

    Does anyone know how to share objects on different tabs of a JTabbedPane? I.e., I want the same buttons/corporate logo to appear on each tab in the same location, and thus the same functionality, locations, look, etc...
    Currently, if I invoke the add(Component) method for the same component but for different panes, only the pane that had the last add() method called contains the object.
    Thanks,
    adam

    An instance of a GUI component can only be in one place in the GUI (visible or not).
    You could make your own component class (extending JPanel and containing other components you want) and then create an instance of this for each tab.

  • How to close a tab in a jtabbedpane?

    Hey all,
    how can i close a tab in a jtabbedpane with an close icon in the title of the tab (such as in JBuilder and LimeWire)?
    Thanks,
    Miklas

    Did you search the forum???
    Using keywords: "+jtabbedpane +close +icon" would be a good place to start.

  • How to Hide a Tab in a jTabbedPane

    Hello, I am trying to toggle the Visibility of a tab in a jTabbedPane... I have tried every permutation of these that I could think of:
    myTab1.Visible(False);
    myTab1.Hide();
    myTab1.updateUI();
    myTabControl.doLayout();
    myTabControl.updateUI();
    myTabControl.repaint();
    myTabControl.Layout();What am i missing?
    Please help.

    Its not complicated
    Object myTabls[]=new Object[tabbedPane.getTabCount()];
    this will create an array.
    now
    for (int a=0;a<tabbedPane.getTabCount();a++)
    myTabs[a]=tabbedPane.getComponentAt(a);
    with an array of Components and their placement (index)
    you can do what you want.
    I think Java Merlin (1.4) has a setVisible for a tab, and my guess is that they have implemented that this way.
    You can do it either way.

  • 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

  • Q on GTX 660 not working in PremPro CS6 also SpeedGrade, heard of tab selection

    I have a newly configured PC with a new GTX 660 video card with a new load of Premiere Pro and can not operate Premiere correctly or load Tiffen Dfx .....so I thought I had purchsed a higher performance card than those recommended ....also I've heard there was a Playback tab selection for utilizing non-offical video cards...Edit>Preferences>Playback    I don't see anything to re-config...Thanks from a flustered Barry

    The feature you're talking about won't be available until the new version comes out June 17th.  For now, you will need to hack the file the old way to get CUDA acceleration working.

  • Tab Selection on odc:TabbedPanel

    Hi All,
    I have jsp with 4 panels in the tabbed panel.. Have got a single <h:form> tab for all panels. Each panel has 2 command buttons.
    Whenever i click a command button on tab 4 .. control comes to the tabl.which i donot want. i want the control to remain in tab 4 itself...
    I tried the solution of including separate form tags for each panel and then set a value in the backing to identify which form is submitted and then hade the below code on jsp
       <f:verbatim>
                                <script>
                                    panel = ODCRegistry.getClientControl('tabbedPanel1');
                                    panel.restoreUIState('bfpanelForm' +
                                        </f:verbatim><h:outputText value="#{masterPublList.submittedForm}"/><f:verbatim>);
                                </script>
    </f:verbatim>..default value of the submittedForm is tab1. but when the tabbed panel is rendered, nothing is selected. and even i click the a btn on tab 4 the control comes to tab 1.. so the solution doesnot seem to work.
    Can anyone help me on this issuse

    The ODC tabbedpanel component in RAD7 should have an option to maintain the tab selected. I don't run RAD6/7 and this was told me so, so I'm sorry I that can't tell you which option exactly it is. I recommend you to just read it's documentation.
    If you're really stuck in it, I recommend you to use the Venkman Javascript Debugger extension to debug the JS involved in maintaining the tab selection. This way I'd found out this hack which is specific for the ODC component as is in WSAD 5.x. The article in http://balusc.xs4all.nl/srv/dev-jep-tab.html also states that it is WSAD 5.x specific.

  • Tab selection property causing 100% CPU usage

    Hi,
    I've having some trouble with using property nodes to tab selection. After 1-2 hours the CPU usage is 100%. The VI is attached. I'm using LV 6.0.2 on win2000. Does anyone have a clue of what's happening?
    Attachments:
    tab_selector_property.vi ‏22 KB

    Every time the while loop executes, you open *new* pages reference array. Whitout closing them, you quickly fill the memory and hog the computer usage. As in the modified VI attached, get the references only once outside the while loop and reuse them. Close any reference after use. As much as possible, you shoud use the control terminal to read its value instead of reading the value property.
    LabVIEW, C'est LabVIEW
    Attachments:
    tab_selector_property.vi ‏25 KB

Maybe you are looking for

  • Ipad 2 with jailbreak, help me

    have an ipad 2 with jailbreak and download whatsapp by pangu in ios 7.1, now delete these programs and profiles that had been created on my iPad to update it but they never updates ios 8 and itunes does not recognize the device on pc, try to erase al

  • Signal problem in new update 141 for a7000

    Since update from 137 to 141, i have 1 problem with my a7000, data connection is to easy to swith from hsdpa to edge, data connection not stable, many user from indonesia feel this problem, i hope next update be better

  • UCCX 8.0 Outbound Scripts

    Hi all, With the Outbound module in UCCX 8.0, we were wondering whether it was possible to show agents more info about the contact they will be calling (when reserved for an outbound call) besides the 6 fields in the Dial List (account number, first

  • Attachement send with FM "SO_NEW_DOCUMENT_ATT_SEND_API1"

    I am sending XL spread sheet in "packing_list" internal table of the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'. My problem is when I try to open received attachment, "Microsoft Excel" gives me a warning message "This file is not a recognizable format". When

  • Adding Period Indicator to New Year after creating draft documents in New Y

    Hi, I want to restart the the numbering from 1 in the New Year and so want to attach a new Period Indicator to the New Year. But i am unable to Add Period Indicator to New Year. It was created with Default Period Indicator and is not allowing any cha