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 883167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:32:37+00:00 2026-05-15T12:32:37+00:00

I have a tab panel where I add tabs dynamically. At a given point

  • 0

I have a tab panel where I add tabs dynamically.

At a given point it can look like:

tabPanel.add(new HTML("Dashboard"), new Hyperlink("Dashboard", "dashboard"));       
tabPanel.add(new CashGameTabPage(this), new Hyperlink("Cash Games", "cash"));
tabPanel.add(new TournamentTabPage(this), new Hyperlink("Tournament", "tournament"));

I would like to check if a Tab already exists. If it exists, I should get its index. If it does not exist I should get 0. I was thinking as a function such as:

public static int getIndexIfAlreadyExists(DecoratedTabPanel tabPanel, String title) {
    int tabcount = tabPanel.getTabBar().getTabCount();      
    for(int i = 0; i < tabcount;i++) {              
       if(/*TODO get a Tab Text */.equals(title))
          return i;
    return 0;
}

I would like to get

getIndexIfAlreadyExists(tabPanel, "Dashboard") -> 0
getIndexIfAlreadyExists(tabPanel, "Cash Games") -> 1
getIndexIfAlreadyExists(tabPanel, "Tournament") -> 2

However I do not manage to find a method to retrieve the Text. Any idea how to achieve this behaviour.

Thanks in advance.

  • 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-05-15T12:32:37+00:00Added an answer on May 15, 2026 at 12:32 pm

    TabPanel doesn’t really make this easy. It may be possible to get the Hyperlink widget somehow via TabPanel.getTabBar().getTab(index), but I’m not sure.

    This is approximately what I would do:

    public class TabPanelModel {
    
        private final List<String> titleList = new ArrayList<String>();
        private final TabPanel tabPanel;
    
        public TabPanelModel(final TabPanel tabPanel) {
            this.tabPanel = tabPanel;
        }
    
        public void addToPanel(Widget widget, final String linktext, final String targetHistoryToken) {
            tabPanel.add(widget, new Hyperlink(linktext, targetHistoryToken));
            titleList.add(linktext);
        }
    
        /* similar for remove, ... */
    
        public int getIndexIfAlreadyExists(final String linktext) {
            return titleList.indexOf(linktext) + 1;
        }
    
    }
    

    The approach uses a small amount of additional memory, but I believe that it’s better to have such information in a clean model anyway.

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

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try: ed.onChange.add(function(ed, o) { var bookmark = ed.selection.getBookmark(); var newContent… May 16, 2026 at 12:05 pm
  • Editorial Team
    Editorial Team added an answer require 'uri' require 'cgi' # use URI.parse to parse the… May 16, 2026 at 12:05 pm
  • Editorial Team
    Editorial Team added an answer AFAIK, you can't point to directories outside the current web… May 16, 2026 at 12:05 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Facebook apps are allowed to have a tab that a user can add to
I have a program wherein there are multiple tabs added dynamically to a TabControl
Problem I have a custom tab control using Chrome-shaped tabs that binds to a
I have this very basic tabbed block: $('.tabbed-section .panel').hide(); $('.tabbed-section .panel:first').show(); $('.tabbed-section .tabs li:first').addClass('active');
I have tab in a web page that loads and displays another page dynamically,
I have ExtJS View-Port panel , that contain center panel, that contain tablpanel ,
All, I have a question regarding Tabbed Panel in Struts2. If I have a
I have tab delimited data that I am exporting a select few columns into
I have got the following very simple code: function init() { var articleTabs =
I am working with dynamic tabs in jQuery . When the user opens a

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.