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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:11:15+00:00 2026-06-09T02:11:15+00:00

What would be the approach to align additional components, such as a button, a

  • 0

What would be the approach to align additional components, such as a button, a label etc. under a specific column of the JTable? I would like to, for instance, add under the column with checkboxes, another checkbox that would select all the values in that particular column.

  • 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-09T02:11:18+00:00Added an answer on June 9, 2026 at 2:11 am

    as far as I understood, usage of TableColumnModelListener, with proper events from resize and reordering

    enter image description here

    enter image description here

    enter image description here

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    
    public class TableFilterRow extends JFrame implements TableColumnModelListener {
    
        private static final long serialVersionUID = 1L;
        private JTable table;
        private JPanel filterRow;   // Panel for text fields
    
        public TableFilterRow() {
            table = new JTable(3, 5);
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            JScrollPane scrollPane = new JScrollPane(table);
            getContentPane().add(scrollPane);
            table.getColumnModel().addColumnModelListener(this);
            filterRow = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
            for (int i = 0; i < table.getColumnCount(); i++) {
                filterRow.add(new JTextField(" Sum at - " + i));
            }
            columnMarginChanged(new ChangeEvent(table.getColumnModel()));
            getContentPane().add(filterRow, BorderLayout.SOUTH);
        }
    
        //  Implement TableColumnModelListener methods
        //  (Note: instead of implementing a listener you should be able to
        //  override the columnMarginChanged and columMoved methods of JTable)
        @Override
        public void columnMarginChanged(ChangeEvent e) {
            TableColumnModel tcm = table.getColumnModel();
            int columns = tcm.getColumnCount();
    
            for (int i = 0; i < columns; i++) {
                JTextField textField = (JTextField) filterRow.getComponent(i);
                Dimension d = textField.getPreferredSize();
                d.width = tcm.getColumn(i).getWidth();
                textField.setPreferredSize(d);
            }
    
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    filterRow.revalidate();
                }
            });
        }
    
        @Override
        public void columnMoved(TableColumnModelEvent e) {
            Component moved = filterRow.getComponent(e.getFromIndex());
            filterRow.remove(e.getFromIndex());
            filterRow.add(moved, e.getToIndex());
            filterRow.validate();
        }
    
        @Override
        public void columnAdded(TableColumnModelEvent e) {
        }
    
        @Override
        public void columnRemoved(TableColumnModelEvent e) {
        }
    
        @Override
        public void columnSelectionChanged(ListSelectionEvent e) {
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    JFrame frame = new TableFilterRow();
                    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like some advice on the best approach to use in the following
I would like to convert this fluent approach to xml: container.Register( AllTypes.FromAssemblyNamed(Company.DataAccess) .BasedOn(typeof(IReadDao<>)).WithService.FromInterface(), AllTypes.FromAssemblyNamed(Framework.DataAccess.NHibernateProvider)
I was wondering how people would approach the problem of merging two 3D objects?
I'm working on a request timeout mechanism. My initial approach would be to create
Based on Constraint for only one record marked as default would the same approach
What would be a good approach in general to cache a web page where
I am wondering what would be the best approach to store, for let's say
Am wondering if there would be any security flaw in this approach. I am
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
I would like to achieve the following structure: [gfhtfg..., kgjrfg..., asd, mrhgf, ] ^-------^

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.