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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:31:35+00:00 2026-06-12T20:31:35+00:00

I am creating one form which contain table and some buttons. A picture is

  • 0

I am creating one form which contain table and some buttons.

A picture is worth a thousand words:

enter image description here

How can I get the checkbox and comboboxes into the table?

I am using NetBeans. I tried using drag and drop but didn’t work.

Here is my form code.

public class HttpOutput extends javax.swing.JPanel {
    HttpElements current_Http_EleObject;
    /**
     * Creates new form HttpOutput
     */
    public HttpOutput(HttpElements httpelements) {
        initComponents();
        current_Http_EleObject=httpelements;
         TableColumn includeColumn = jTable1.getColumnModel().getColumn(0);
            includeColumn.setCellEditor(new DefaultCellEditor(new JCheckBox()));
    }  
  • 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-06-12T20:31:36+00:00Added an answer on June 12, 2026 at 8:31 pm

    Here is combo cell insets replicate demo:

    enter image description here

    import java.awt.*;
    import java.awt.event.*;
    import java.util.EventObject;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    
    public class ComboCellInsetsDemo {
      public JComponent makeUI() {
        String[] columnNames = {"Name", "Check", "Condition"};
        Object[][] data = {
          {"bbb", false, "="}, {"aaa", true, "<"}
        };
        DefaultTableModel model = new DefaultTableModel(data, columnNames) {
          @Override public Class<?> getColumnClass(int column) {
            return getValueAt(0, column).getClass();
          }
        };
        JTable table = new JTable(model);
        table.setRowHeight(36);
        table.setAutoCreateRowSorter(true);
        TableColumn column = table.getColumnModel().getColumn(2);
        column.setCellRenderer(new ComboBoxCellRenderer());
        column.setCellEditor(new ComboBoxCellEditor());
        return new JScrollPane(table);
      }
      public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
          @Override public void run() {
            createAndShowGUI();
          }
        });
      }
      public static void createAndShowGUI() {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        f.getContentPane().add(new ComboCellInsetsDemo().makeUI());
        f.setSize(320, 240);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
      }
    }
    
    class ComboBoxPanel extends JPanel {
      private String[] m = new String[] {">", "<", "=", "<="};
      protected JComboBox<String> comboBox = new JComboBox<String>(m) {
        @Override public Dimension getPreferredSize() {
          Dimension d = super.getPreferredSize();
          return new Dimension(40, d.height);
        }
      };
      public ComboBoxPanel() {
        super();
        setOpaque(true);
        comboBox.setEditable(true);
        add(comboBox);
      }
    }
    class ComboBoxCellRenderer extends ComboBoxPanel
                               implements TableCellRenderer {
      public ComboBoxCellRenderer() {
        super();
        setName("Table.cellRenderer");
      }
      @Override public Component getTableCellRendererComponent(
          JTable table, Object value, boolean isSelected,
          boolean hasFocus, int row, int column) {
        setBackground(isSelected?table.getSelectionBackground()
                                :table.getBackground());
        if(value!=null) {
          comboBox.setSelectedItem(value);
        }
        return this;
      }
    }
    class ComboBoxCellEditor extends ComboBoxPanel
                             implements TableCellEditor {
      public ComboBoxCellEditor() {
        super();
        comboBox.addActionListener(new ActionListener() {
          @Override public void actionPerformed(ActionEvent e) {
            fireEditingStopped();
          }
        });
        addMouseListener(new MouseAdapter() {
          @Override public void mousePressed(MouseEvent e) {
            fireEditingStopped();
          }
        });
      }
      @Override public Component getTableCellEditorComponent(
          JTable table, Object value, boolean isSelected, int row, int column) {
        this.setBackground(table.getSelectionBackground());
        comboBox.setSelectedItem(value);
        return this;
      }
    
      //Copid from DefaultCellEditor.EditorDelegate
      @Override public Object getCellEditorValue() {
        return comboBox.getSelectedItem();
      }
      @Override public boolean shouldSelectCell(EventObject anEvent) {
        if(anEvent instanceof MouseEvent) {
          MouseEvent e = (MouseEvent)anEvent;
          return e.getID() != MouseEvent.MOUSE_DRAGGED;
        }
        return true;
      }
      @Override public boolean stopCellEditing() {
        if(comboBox.isEditable()) {
          comboBox.actionPerformed(new ActionEvent(this, 0, ""));
        }
        fireEditingStopped();
        return true;
      }
    
      //Copid from AbstractCellEditor
      //protected EventListenerList listenerList = new EventListenerList();
      transient protected ChangeEvent changeEvent = null;
    
      @Override public boolean isCellEditable(EventObject e) {
        return true;
      }
      @Override public void  cancelCellEditing() {
        fireEditingCanceled();
      }
      @Override public void addCellEditorListener(CellEditorListener l) {
        listenerList.add(CellEditorListener.class, l);
      }
      @Override public void removeCellEditorListener(CellEditorListener l) {
        listenerList.remove(CellEditorListener.class, l);
      }
      public CellEditorListener[] getCellEditorListeners() {
        return listenerList.getListeners(CellEditorListener.class);
      }
      protected void fireEditingStopped() {
        // Guaranteed to return a non-null array
        Object[] listeners = listenerList.getListenerList();
        // Process the listeners last to first, notifying
        // those that are interested in this event
        for(int i = listeners.length-2; i>=0; i-=2) {
          if(listeners[i]==CellEditorListener.class) {
            // Lazily create the event:
            if(changeEvent == null) changeEvent = new ChangeEvent(this);
            ((CellEditorListener)listeners[i+1]).editingStopped(changeEvent);
          }
        }
      }
      protected void fireEditingCanceled() {
        // Guaranteed to return a non-null array
        Object[] listeners = listenerList.getListenerList();
        // Process the listeners last to first, notifying
        // those that are interested in this event
        for(int i = listeners.length-2; i>=0; i-=2) {
          if(listeners[i]==CellEditorListener.class) {
            // Lazily create the event:
            if(changeEvent == null) changeEvent = new ChangeEvent(this);
            ((CellEditorListener)listeners[i+1]).editingCanceled(changeEvent);
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating one form in html using table. Which have one Drop down
I am creating one application in java-script which fetch information form LinkedIn which we
I am creating a VC++2008 Windows Form Application which needs to use some of
I am creating a JPanel form which will contain several other JPanels. I want
I've creating one ASP web application, in that application one form have to update
I was creating sixth form for a simple one digit user input and it
I am creating one application in which i am using jsp/servlet.. I want to
I am creating a travel theme in which I have created some custom posts
My dilema is in creating one method that follows the builder pattern, which sets
I am working on creating a form section which shows input fields (either text

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.