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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:06:53+00:00 2026-05-23T15:06:53+00:00

I am creating a java app. I have one class q2a2 which is a

  • 0

I am creating a java app.

I have one class q2a2 which is a jpanel whose design is shown as follows: -img-

enter image description here

Suppose if an item is selected from the combo-box and “Create Account” button is clicked. One tab is added to the jTabbedPane. every item has a common tab. so what i did is created one class and adding that everytime on button click. The class name is q2a2_add. This is a panel as well. The image for this is as follows…

enter image description here

After having some three items the app looks like

enter image description here

The code for this is:

public void addclass(int a) {
    if(jTabbedPane1.getTabCount()<13) { //variable name of TabbedPane
    String s=(String) mainCB.getItemAt(a); //mainCB is the variable name of main combobox
    int dont=0;
        for(int j=0;j<tabname.length;j++){ //just to ensure two accounts should not be same
        if(s.equals(tabname[j])){
            dont=1;
            break;
        }
        }
        if(dont==0){         
        for(int j=0;j<12;j++) {
            if(index[j]==0){
                q2a2_add subpanel2=new q2a2_add(this); //calling the second class
                jTabbedPane1.add(s,subpanel2); //here adding panel
                subpanel2.heading(s); // heading() method is defined in q2a2_add() which rename the jTextField to be same as argument s;
                tabname[j]=s;
                index[j]=1;
                break;
            }
        }
        }
        else {
            JOptionPane.showConfirmDialog(null, (String) mainCB.getItemAt(a)+" is already created","Information", JOptionPane.PLAIN_MESSAGE);
        }
}
    else {
            JOptionPane.showConfirmDialog(null, "Account Overload. Delete wrong account and then create","Caution", JOptionPane.PLAIN_MESSAGE);
    }
}

Now my question is. As seen in the function. everytime same class has been called and added. How can i access the various comboboxes and textboxes in different tabs. I want to store and opearate values entered by the user. Like for example- how to read inputs from Accounts Receivable, Accounts Payable and Office Supplies differently.

Please reply.

  • 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-23T15:06:54+00:00Added an answer on May 23, 2026 at 3:06 pm

    I would expose the functionality that you require within your q2a2_add class. For instance, if you want to change the textbox value, add a function inside the q2a2_add class called setTextBoxValue() that takes a String parameter. Inside that function, you can set the textbox value. The same goes for retrieving information from it. The only remaining problem is how to keep track of the different tabs. What I would recommend (which may simplify what you already have) is to create a HashMap which maps String types to q2a2_add types. Then, when you want to add a new tab panel, you can just check if the String exists in the HashMap instead of searching through to check the titles. If it doesn’t exist, you can add it to a HashMap stored inside of your outer JPanel class. Then, when you want to access the tabpanels, you can simply access them by string inside the HashMap and get/set their properties as you please.

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

Sidebar

Related Questions

We have a one Java Swing app. Now there is one requirement that it
I have to call the web service using java script? e.g. I'm creating one
I am creating a java swing app which makes use of the JProgressBar control.
To the best of my knowledge, creating a dynamic Java proxy requires that one
I am using Java back end for creating an XML string which is passed
I am creating an application in java which will be the part of an
We have your bog standard Java app under development, and a lot of the
I'm creating a Java app that creates 4 PDF files using iText. On the
Suppose I am creating an Android application that's like an SMS app. The requirements
The one class per file rule in Java has me a bit confused. I

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.