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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:21:06+00:00 2026-05-27T04:21:06+00:00

I have two combo boxes in two different classes. My requirement is that if

  • 0

I have two combo boxes in two different classes. My requirement is that if I change the data in one class that data should be displayed in other class. Are there any listeners or some other way? Can u help me?

  • 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-27T04:21:06+00:00Added an answer on May 27, 2026 at 4:21 am

    You can use Object of the second class and then access textfield of that class set the value

    Sample

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    
    public class ComboBox{
      JComboBox combo;
      JTextField txt;
      static ComboBox b1 = null;
      static ComboBox b2 = null;
      public static void main(String[] args) {
      b1 = new ComboBox();
      b2 = new ComboBox();
      }
    
      public ComboBox(){
      String course[] = {"BCA","MCA","PPC","CIC"};
      JFrame frame = new JFrame("Creating a JComboBox Component");
      JPanel panel = new JPanel();
      combo = new JComboBox(course);
      combo.setBackground(Color.gray);
      combo.setForeground(Color.red);
      txt = new JTextField(10);
      panel.add(combo);
      panel.add(txt);
      frame.add(panel);
      combo.addItemListener(new ItemListener(){
      public void itemStateChanged(ItemEvent ie){
      String str = (String)combo.getSelectedItem();
      b1.txt.setText(str);
      b2.txt.setText(str);
      }
      });
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(400,400);
      frame.setVisible(true);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two combo boxes, one for 'order by' and the other 'direction' (ascending,
I have two classes, and want to include a static instance of one class
I have in a form two combo boxes that have the exact itemssource property.
I have cascading data-bound combo boxes, however, if the second of the two boxes
I have five combo boxes. Each one has a different name, but the possible
I have a data entry/editing form with two combo boxes (Name and Group). Each
I have two dependent combo-boxes and the value of second one is populated after
I have two combo boxes. Let's say the first one had values A, B,
I have a form in VB6 with two combo boxes (cboCustomer and cboItemNumber). When
I have two applications written in Java that communicate with each other using XML

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.