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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:27:00+00:00 2026-05-12T00:27:00+00:00

I have two panels that i wish to display to the user. I decided

  • 0

I have two panels that i wish to display to the user. I decided to add them to a JTabbedPane. I also want to allow the user to have a side by side view of them both at the same time. So I added the two panels to my JTabbedPane and then i created a JSplitPanel as such :

    tabs.addTab("Align Image Points", imageControlPanel);
    tabs.addTab("Align Map Points", mapControlPanel);
    JSplitPane splitPane = new JSplitPane(
            JSplitPane.HORIZONTAL_SPLIT, true, imageControlPanel,
            mapControlPanel);
    tabs.addTab("Side by side view", splitPane);

The resulting JTabbedPane only has one tab! When i remove the JSplitPane everything works ok. Two tabs. I then tried simplifying the problem to post here and i came up with this :

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;

public class Test {

    public static void main(String[] args) {
        JFrame f = new JFrame("Test");
        JButton b1 = new JButton("First");
        JButton b2 = new JButton("Second");
        JSplitPane s = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,b1,b2);
        JTabbedPane tabs = new JTabbedPane();
        tabs.addTab("First", b1);
        tabs.addTab("Second", b2);
        tabs.addTab("Both", s);
        f.getContentPane().add(tabs);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.pack();
        f.setVisible(true);
    }

}

This gave me another problem! It displays 3 tabs but the third tab’s split pane displays no buttons!

So my question is What is wrong with JSplitPanel? You can’t have it display objects that are already displayed in another tab? It makes no sense. Please help me.

(Note: i don’t want to duplicate the components that i am about to display as i want them to be the same reference)

  • 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-12T00:27:01+00:00Added an answer on May 12, 2026 at 12:27 am

    I had the same problem that you had. what I had resolved for this issue, I made the each GUI as MVC pattern(Model-view-controller) that controller knows how to iterative with gui components.

    I created a new instance of GUIs(View) on each Tab;however, I injected the same instance of controller for that GUI as constructor parameter since the controller knows how to handle GUI flow and behaviors.

    for example,

        GUIView1Controller controller1 = new GUIView1Controller();
        GUIView2Controller controller2 = new GUIView2Controller();
    
        // Add new instance GUI ; however , use the same instance of controller
        JSplitPane s = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,
                           new GUIView1(controller1), new GUIView2(controller2));
    
       JTabbedPane tabs = new JTabbedPane();
       tabs.addTab("First", new GUIView1(controller1));
       tabs.addTab("Second", new GUIView2(controller2));
       tabs.addTab("Both",  s );
    

    GUIView1 and GUIView2 will register all GUI listeners to the controller, so the controller will be notified and take an action for the listeners. whatever the GUIView1 on “First” tab is changed, the GUIView1 on “Both” tab also is updated as the same behaviors of the GUIView1 on “First” tab.

    The drawback was you have to create a new instance of the GUIView on the tab and JSplitPane; however, the controller can control and share all gui events and behaviors.

    I hope it helps.

    Tiger.

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

Sidebar

Related Questions

I have two panels that I want to organize onto another panel. I need
I have a page that renders two panels that display the same data differently
I have two update panels on a page. And I want to update both
I have a TStatusBar that contains two status panels. The first one is about
I have a user control where I have two panels, one is on the
I have two pages. Search page is the first page that takes user inputs.
I have two panels, and when the first panel is scrolled, I want the
I have two panels, and when the first panel is scrolled, I want the
I have an application that can display items in two different ways, in rows
Let's say I have two different, distinct stack panels (we'll call them SPA and

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.