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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:56:02+00:00 2026-05-16T11:56:02+00:00

I want to implement a properties table in jtable (swing). I want to have

  • 0

I want to implement a properties table in jtable (swing).
I want to have e.g.

**
2 column table

Row1: Property-text| Txtbox. Row2:
Property-text| ComboBox of values
A,B,C. Row3: Property-text| Txtbox.
Row4: Property-text| ComboBox of
values E,F,G.

**

I can not understand how to get this started. I am using Netbeans.
I need to implement a celltableeditor or what?

Thanks

  • 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-16T11:56:02+00:00Added an answer on May 16, 2026 at 11:56 am

    The first example shows how you can specify a different editor for each row in the table:

    import java.awt.*;
    import java.awt.event.*;
    import java.util.List;
    import java.util.ArrayList;
    import javax.swing.*;
    import javax.swing.table.*;
    
    public class TableComboBoxByRow extends JFrame
    {
        List<TableCellEditor> editors = new ArrayList<TableCellEditor>(3);
    
        public TableComboBoxByRow()
        {
            // Create the editors to be used for each row
    
            String[] items1 = { "Red", "Blue", "Green" };
            JComboBox comboBox1 = new JComboBox( items1 );
            DefaultCellEditor dce1 = new DefaultCellEditor( comboBox1 );
            editors.add( dce1 );
    
            String[] items2 = { "Circle", "Square", "Triangle" };
            JComboBox comboBox2 = new JComboBox( items2 );
            DefaultCellEditor dce2 = new DefaultCellEditor( comboBox2 );
            editors.add( dce2 );
    
            String[] items3 = { "Apple", "Orange", "Banana" };
            JComboBox comboBox3 = new JComboBox( items3 );
            DefaultCellEditor dce3 = new DefaultCellEditor( comboBox3 );
            editors.add( dce3 );
    
            //  Create the table with default data
    
            Object[][] data =
            {
                {"Color", "Red"},
                {"Shape", "Square"},
                {"Fruit", "Banana"},
                {"Plain", "Text"}
            };
            String[] columnNames = {"Type","Value"};
            DefaultTableModel model = new DefaultTableModel(data, columnNames);
            JTable table = new JTable(model)
            {
                //  Determine editor to be used by row
                public TableCellEditor getCellEditor(int row, int column)
                {
                    int modelColumn = convertColumnIndexToModel( column );
    
                    if (modelColumn == 1 && row < 3)
                        return editors.get(row);
    //                  return (TableCellEditor)editors.get(row);
                    else
                        return super.getCellEditor(row, column);
                }
            };
            System.out.println(table.getCellEditor());
    
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
        }
    
        public static void main(String[] args)
        {
            TableComboBoxByRow frame = new TableComboBoxByRow();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setVisible(true);
        }
    }
    

    The second example shows how you can create a very basic property editor (although it doesn’t support combo boxes):

    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    
    public class TablePropertyEditor extends JFrame
    {
        public TablePropertyEditor()
        {
            String[] columnNames = {"Type", "Value"};
            Object[][] data =
            {
                {"String", "I'm a string"},
                {"Date", new Date()},
                {"Integer", new Integer(123)},
                {"Double", new Double(123.45)},
                {"Boolean", Boolean.TRUE}
            };
    
            JTable table = new JTable(data, columnNames)
            {
                private Class editingClass;
    
                public TableCellRenderer getCellRenderer(int row, int column)
                {
                    editingClass = null;
                    int modelColumn = convertColumnIndexToModel(column);
    
                    if (modelColumn == 1)
                    {
                        Class rowClass = getModel().getValueAt(row, modelColumn).getClass();
                        return getDefaultRenderer( rowClass );
                    }
                    else
                        return super.getCellRenderer(row, column);
                }
    
                public TableCellEditor getCellEditor(int row, int column)
                {
                    editingClass = null;
                    int modelColumn = convertColumnIndexToModel(column);
    
                    if (modelColumn == 1)
                    {
                        editingClass = getModel().getValueAt(row, modelColumn).getClass();
                        return getDefaultEditor( editingClass );
                    }
                    else
                        return super.getCellEditor(row, column);
                }
    
                //  This method is also invoked by the editor when the value in the editor
                //  component is saved in the TableModel. The class was saved when the
                //  editor was invoked so the proper class can be created.
    
                public Class getColumnClass(int column)
                {
                    return editingClass != null ? editingClass : super.getColumnClass(column);
                }
            };
    
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
        }
    
        public static void main(String[] args)
        {
            TablePropertyEditor frame = new TablePropertyEditor();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
        }
    }
    

    You should be able achieve what you want by using the suggestions from one or both of the above examples.

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

Sidebar

Related Questions

I want to implement a simple debug log, which consists of a table into
I want to implement search functionality for a website (assume it is similar to
I want to implement an automatic update system for a windows application. Right now
I want to implement a paperless filing system and was looking to use WIA
I want to implement in Java a class for handling graph data structures. I
I want to implement a two-pass cache system: The first pass generates a PHP
I want to implement an ISAPI filter like feature using HttpModule in IIS7 running
I want to implement user stories in a new project where can i find
I want to implement forms authentication on an ASP.NET website, the site should seek
I want to implement the solution using the pre-processor described here: Reuse define statement

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.