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

  • Home
  • SEARCH
  • 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 6203263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:53:05+00:00 2026-05-24T04:53:05+00:00

I have 2 frames. One contains buttons that do appropriate actions on data. And

  • 0

I have 2 frames. One contains buttons that do appropriate actions on data. And secnd frame which contains data in tab view.
Now I have to add one button in first frame by clicking on this button a new tab should be added on second frame. How can I 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-05-24T04:53:06+00:00Added an answer on May 24, 2026 at 4:53 am

    Make the JTabbedPane of the second frame accessible in first frame and then just simply call add() method of JTabbedPane to add a new tab in it.

    Following is a sample code for that:

    First frame:-

    JFrame frame = new JFrame("Demo");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.setSize(250,250);
    JButton button = new JButton("Add tab to another frame.");
    button.addActionListener(this);
    frame.add(button);
    frame.setVisible(true);
    

    Second frame:-

    Decalre a global variable of tabbedPane

    JTabbedPane tabs;
    int i = 0; // just a tab counter. You might not need this.
    

    Initializaition code

    JFrame frame2 = new JFrame("Demo 2");
    frame2.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame2.setSize(250,250);
    tabs = new JTabbedPane();
    frame2.add(tabs);
    frame2.setVisible(true);
    

    Action on button click in first frame:-

    public void actionPerformed(ActionEvent e) {
        JPanel panel = new JPanel();
        panel.add(new JLabel("tab number "+i));
        tabs.add((i++)+"",panel); //--access tabbedPane of second frame here.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some web pages which have two frames, with one frame in the
Suppose I have one html page with frames. The left frame is simply a
I have a bowling web application that allows pretty detailed frame-by-frame information entry. One
I have a list of (64-bit) addresses that represent a stack frame, and I
I have a WPF Window which has a among other controls hosts a Frame.
I have a website where each page contains a few frames. I recently started
Say I have 3 frames in a frameset arranged in 3 rows. Frames 1
I having trouble in dividing the HTML frames. I have been using the following
I have no frame of reference in terms of what's considered fast; I'd always
I have subclassed java.awt.Frame and have overridden the paint() method as I wish to

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.