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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:15:42+00:00 2026-05-24T18:15:42+00:00

in my project I’ve several JComboBox with their custom models. Basically they are used

  • 0

in my project I’ve several JComboBox with their custom models. Basically they are used to show values of some JTables column (therefore I decided to implement them on the relative
class extending AbstractTableModel).

public class MyTableModel1 extends AbstractTableModel{

    protected class MyTableComboBoxModel1 extends AbstractListModel implements ComboBoxModel{

        private Object selected;
        @Override
        public Object getElementAt(int index) {
            return getValueAt(index, 1);
        }

        @Override
        public int getSize() {
            return getRowCount();
        }

        @Override
        public Object getSelectedItem() {
                 return this.selected;

        }

        @Override
        public void setSelectedItem(Object anItem) {
                     this.selected = anItem;
        }

    }
}

And I have several models : MyTableModel2 with MyTableComboBoxModel2. These models all do pretty the same thing except some additional operations not related neither with the combobox nor with the table itself.

The purpose of all this stuff should be to update JComboBox’s displayed values accordingly to modifications occured to the relative JTable.

All works fine for models I’ve implemented except in one case , and after several hours of debug I still can’t solve it. The code of the bugged model is almost identical to the others. Probably it’s a bug somewhere else in my code, but I can’t figure out where.

The wrong case has the following behavior: when I initially created a table with some values these are correctly displayed even in the JComboBox, but when I add a new row the displayed values become all blank (the size of the displayed blank menu is right).
I found out that:

  1. the new row of the jtable is added correctly.
  2. the getElementAt method is called several times when clicked on the JComboBox and return all the available values (including the new ones).
  3. the method getSize() is called when I click the JComboBox and return the right updated value
  4. If JComboBox has focus I can use arrows to select the available items and all items are selectable (even the added ones).
  5. If I use the mouse clicking one point at random on the displayed blank menu, all the last available entry could be chosen.

Has someone any idea? Could you suggest me how could I debug in such a situation? Unfortunately I can’t post an SSCCE.. I hope someone could help anyway..

  • 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-24T18:15:43+00:00Added an answer on May 24, 2026 at 6:15 pm

    I know that my question is a bit vague

    Which is why a SSCCE is required.

    Each combo box should show all the value of a particular column of an existing JTable

    I don’t understand why you need a custom model. I would guess you just need to use a TabelModelListener.

    Whenever a value is added/removed you updated the combo box.

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

Sidebar

Related Questions

Every project invariably needs some type of reporting functionality. From a foreach loop in
My project is currently using a svn repository which gains several hundred new revisions
Project was running fine, i made a change some where and couldn't figure out
Project Euler I have recently begun to solve some of the Project Euler riddles.
Project: I am having a button that toggles the column length from 3 to
Project background aside, I've implemented a table of custom JComboBoxes. Each row of ComboBoxes
My project has some references. One of them has no path. I can't view
Project#1 has some interfaces and classes that project#2 references. Now I want to use
Project: ASP.NET 3.5 with C# I have this much :- A table which used
Project info: WPF, PRISM, C# 4.0, WCF, Entity framework, SQL(express) My database contains several

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.