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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:28:34+00:00 2026-05-27T22:28:34+00:00

I use the following code for retrieve the data into combobox. How to change

  • 0

I use the following code for retrieve the data into combobox. How to change Jcombobox into Auto suggested combobox . It means when I press A the words which are start with A that will show in the items field in combobox.

public void combo(){

     try{
                GCS.GContnStr();
                TmpFlxTSt= GCS.GCotnStr.createStatement();
                String select = "Select StudName from studentmaster";
                TmpFlxTRs = TmpFlxTSt.executeQuery(select);

                  while(TmpFlxTRs.next())
                  {
                      String TmpOb1=TmpFlxTRs.getString("StudName");
                      TmpOb1.toString();
                      cbx.addItem(TmpOb1);
                      cbx.setMaximumRowCount(1);

                    }
  • 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-27T22:28:35+00:00Added an answer on May 27, 2026 at 10:28 pm
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.plaf.basic.*;
    
    
    class Test
    {
          private JComboBox_ cb = null;
    
    
        public Test() {
            JFrame fr=new JFrame("TEST ComboBox");
        JPanel p = new JPanel();
            p.setLayout( new BorderLayout() );
            String[] ss = new String[]
            {  "112","1123","1124","1134",
               "first",
               "second",
               "third",
               "third 1 before",
               "third 2",
               "third 1 after",
               "third quarter",
               "fourth",
               "fourth and more",
               "fourth and more and more"
            };
        fr.getContentPane().add(p);
            cb = new JComboBox_(ss);
    
            p.add("South",cb);
            p.add("Center",new JButton("test combo box"));
            fr.pack();
            fr.show();
        }
        public static void main( String[] args ) {
          Test test=new Test();
        }
    }
    
    class JComboBox_ extends JComboBox {
        public int caretPos=0;
        public JTextField tf=null;
        public JComboBox_(final Object items[]) {
            super(items);
            this.setEditor(new BasicComboBoxEditor());
            this.setEditable(true);
        }
    
        public void setSelectedIndex(int ind) {
            super.setSelectedIndex(ind);
            tf.setText(getItemAt(ind).toString());
            tf.setSelectionEnd(caretPos+tf.getText().length());
            tf.moveCaretPosition(caretPos);
    //        tf.setSelectionStart(caretPos);
        }
        public void setEditor(ComboBoxEditor anEditor) {
            super.setEditor(anEditor);
            if (anEditor.getEditorComponent() instanceof JTextField) {
                tf=(JTextField)anEditor.getEditorComponent();
                tf.addKeyListener(new KeyAdapter()
                      {
                            public void keyReleased( KeyEvent ev )
                            {
                              char key=ev.getKeyChar();
                              if (! (Character.isLetterOrDigit(key)||Character.isSpaceChar(key) )) return;
                              String s = tf.getText();
                              caretPos=tf.getCaretPosition();
                              String text="";
                              try {
                                text=tf.getText(0,caretPos);
                              }
                              catch (Exception ex) {
                                ex.printStackTrace();
                              }
                              int n=getItemCount();
                              for (int i=0; i<n; i++) {
                                int ind=((String)getItemAt(i)).indexOf(text);
                                if (ind==0) {
                                  setSelectedIndex(i);
                                  return;
                                }
                              }
                            }
              } );
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently use the following code to retrieve and decompress string data from Amazon
I have tried to use the following code to retrieve the data from the
I use the following code for retrieve the data from my Sql DB.retrieve StudName
I use the following code for retrieve the data from mysql Student data Base.It
Currently I use the following code to retrieve the IP address of the local
I use the following code to load an image into an scroll view. The
I use the following code to retrieve image from the phone or SDCard and
I use the following code to display list of contacts, and then retrieve contact
I wrote the following code to retrieve data about stocks in the S&P 500.
I use the following code to create countdowns in Javascript. n is the number

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.