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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:04:07+00:00 2026-05-29T04:04:07+00:00

I am populating Employee Data in JTable using Netbeans. I want to add Radiobutton

  • 0

I am populating Employee Data in JTable using Netbeans. I want to add Radiobutton in each row, so that user can select any row and can perform actions like Update/Delete,etc.
Here is my code for TableModel:

    DefaultTableModel model = new DefaultTableModel();

    model.setColumnIdentifiers(new String[] {"Select","Employee ID","Name","Surname","Birth Place","Genre","Home","Marital Status","Phone","Age","Department"});
    try{
    con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/"+database,"root","123456");
    Statement s = con.createStatement ();
    s.executeQuery ("SELECT * FROM Employee");
    ResultSet rs = s.getResultSet ();
    rs.next ();
    String eid = rs.getString ("emp_no");
    String name = rs.getString ("name");
    String surname = rs.getString ("surname");
    String pbirth = rs.getString ("place_birth");
    String genre = rs.getString ("genre");
    String home = rs.getString ("home");
    String mstatus = rs.getString ("marital_status");
    String ph = rs.getString ("phone");
    int age = rs.getInt ("age");
    String dept = rs.getString ("department");
    for(int i=0;i<30;i++)
    model.addRow(new Object[] {?,eid, name, surname, pbirth, genre, home, mstatus, ph, age, dept});
    }
    catch (Exception e){

    }
    this.jTable1.setModel(model);

In first column of every row i want to insert a radiobutton. Please suggest me.
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-29T04:04:08+00:00Added an answer on May 29, 2026 at 4:04 am

    You have to implement TableCellEditor and override getTableCellEditorComponent like this

    public java.awt.Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
    
    {
                return new JRadioButton();
    }
    

    Hope this helps

    EDIT:
    You can write like this

    this.jTable1.getColumnModel().getColumn(0).setCellEditor(new javax.swing.table.TableCellEditor(){
        @Override
        public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column) {
            return new javax.swing.JRadioButton();
        }
    
        @Override
        public java.lang.Object getCellEditorValue() {
    return null;//Here you can return the radio button status
        }
    
        @Override
        public boolean isCellEditable(java.util.EventObject anEvent) {
            return false; //uneditable cell
        }
    
        @Override
        public boolean shouldSelectCell(java.util.EventObject anEvent) {
            return false;
        }
    
        @Override
        public boolean stopCellEditing() {
            return true;
        }
    
        @Override
        public void cancelCellEditing() {       
        }
    
        @Override
        public void addCellEditorListener(javax.swing.event.CellEditorListener l) {
        }
    
        @Override
        public void removeCellEditorListener(javax.swing.event.CellEditorListener l) {
        }
    
    });
    

    You can take out the cell editor implementation to a separate class.

    Also you have to set the flags accordingly to your requirement.

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

Sidebar

Related Questions

im populating the data in the combo box using dataset tables...with some table name..now
I m populating data for different entities into set of lists using generic lists
I am creating and populating a list with jQuery and want to add an
As my gridview is populating I want to add an extra column with some
I am populating different types objects with datarows with each attrivute of the relevant
I'm populating a ListView with items and add images from an ImageList (in the
I'm working on populating a combobox in visual studio 2005 using vb and I'm
I am populating a list of names that will be added to my Sql
I am populating a JComboBox (using addItem() ) with all the elements of a
I am populating a list using List<Country> countries = new List<Country> { new Country()

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.