Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8300949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:45:08+00:00 2026-06-08T16:45:08+00:00

I have a JTabPanel with three tabs, two of which start disabled. I want

  • 0

I have a JTabPanel with three tabs, two of which start disabled. I want enable them when they have been given content (otherwise some of the fields and boxes are blank and/or meaningless).

It seems the only way to set whether a tab is enabled or disabled is to pass setEnabledAt an int for the tab index and the boolean. The only way I can find to pass the index of a tab to something is to use indexOfTabComponent and pass in the panel to swap to….This seems horrible, and doesn’t work. I’m getting java.lang.ArrayIndexOutOfBoundsException: -1 when I try and swap to the tab at index 1.

Is there a better way than this?

public void swapView(JPanel paneToSelect) {
    myContainerPane.getMyPaneTab().setSelectedComponent(paneToSelect);
    myContainerPane.getMyPaneTab().setEnabledAt(myContainerPane.getMyPaneTab().indexOfTabComponent(paneToSelect), true);
}

The only solution I can think of is to add 2 to the index number…but it feels there should be a better way to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T16:45:09+00:00Added an answer on June 8, 2026 at 4:45 pm

    The correct code to use is:

    public void swapView(JPanel paneToSelect) {
        int index = myContainerPane.getMyPaneTab().indexOfComponent(paneToSelect);
        myContainerPane.getMyPaneTab().setSelectedIndex(index);
        myContainerPane.getMyPaneTab().setEnabledAt(index, true);
    }
    

    The difference being is that, for whatever reason indexOfTabComponent, does not work with my set up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tabs. I want load then on demand except first tab. If
Have deployed numerous report parts which reference the same view however one of them
I have a tabpanel where some tabs are hidden. How can i check which
1-I have three user controls. 2-I added them to AJAX TabContainer on my default.aspx
I have a tab panel with two tabs and a toolbar at the top
I have a popup with three tabs in primefaces tabPanel. In the middle is
I have many tabs in tabcontainer on my asp page. I want to set
I have TabPanel which contains, among other things, a Grid connected to a Store.
I have a TabPanel, where the TabPanel contains two parts, one part has details
Let's consider following, simplified example: We have 2 tabs withing <rich:tabPanel switchType=ajax> , each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.