Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: traversing multiple jTabbedPane?

Threaded View

  1. #1
    Junior Member
    Join Date
    May 2009
    Location
    Rochester, NY
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default traversing multiple jTabbedPane?

    I have 3 jTabbedPane in my application which visibility switches based on other selections in the app. what I want to do is have a single set of navigation buttons (back) (next) that will traverse the visible jTabbedPane. I can do it with 3 sets of essentially the same code but am trying to keep this app as small as possible. how can i reference the visible jTabbedPane in my traversal code without writing the same code for each jTabbedPane?

    Here is the code that traverses the tabs
        public void switchTabs(String action) {
            Integer tabCount = tabContainer.getTabCount() - 1;
            Integer currentTab = tabContainer.getSelectedIndex();
            if (action.equals("back")) {
                if (currentTab > 0) {
                    nextButton.setEnabled(true);
                    currentTab -= 1;
                    while (!tabContainer.isEnabledAt(currentTab) && currentTab > 0){
                        currentTab -= 1;
                    }
                    tabContainer.setSelectedIndex(currentTab);
                }
            } else if (action.equals("next")) {
                if (currentTab < tabCount) {
                    backButton.setEnabled(true);
                    currentTab += 1;
                    while (!tabContainer.isEnabledAt(currentTab) && currentTab < tabCount){
                        currentTab += 1;
                    }
                    tabContainer.setSelectedIndex(currentTab);
                }
            } else if (action.equals("reset")) {
                tabContainer.setSelectedIndex(0);
                currentTab = 0;
            }
            if (currentTab == tabCount){
                nextButton.setEnabled(false);
                backButton.setEnabled(true);
            } else if (currentTab == 0){
                nextButton.setEnabled(true);
                backButton.setEnabled(false);
            } else {
                nextButton.setEnabled(true);
                backButton.setEnabled(true);
            }
            //calculate();
        }

    If I could pass the jTabbedPane I want to work with into switchTabs(), it would be perfect but I do not know how to do that and haven't been able to find any information through searching. Any ideas would be helpful. Thank you.
    Last edited by dewboy3d; May 30th, 2009 at 01:54 PM. Reason: code typo
    --
    DewBoy3d
    Rochester, NY


Similar Threads

  1. Which interface gives more control on serialization of an object?
    By abhishekraok2003 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 16th, 2009, 10:17 AM
  2. Replies: 2
    Last Post: May 16th, 2009, 05:23 AM
  3. Replies: 6
    Last Post: May 15th, 2009, 05:06 PM
  4. [SOLVED] Need to display multiple images from database on a webpage
    By raghuprasad in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: May 13th, 2009, 03:15 AM