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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:13:51+00:00 2026-05-13T12:13:51+00:00

Is it possible to add buttons inside the JTable cell along with data? What

  • 0

Is it possible to add buttons inside the JTable cell along with data?
What I am trying to do is to create a table with columns which display data(number) from the database, and two buttons to increase/decrease the number inside the same cell.

|ID | Quantity|
|06| 2 [+][-] |

it would be something like above with [+][-] being buttons. So when I press [+], the number will change to 3 and 1 if pressing [-].

  • 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-13T12:13:51+00:00Added an answer on May 13, 2026 at 12:13 pm

    Yes, it is possible, although It won’t be easy.

    You have to write your own custom cell renderer and your own cell editor.

    This is a sample I made in 5 minutes:

    sample

    It is far from perfect, but shows the concept.

    Here’s the source code:

    import java.awt.Component;
    import java.awt.Font;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.Dimension;
    
    public class CustomCell {
        public static void main( String [] args ) { 
            Object [] columnNames = new Object[]{ "Id", "Quantity" };
            Object [][] data        = new Object[][]{ {"06", 1}, {"08", 2} };
    
            JTable table = new JTable( data, columnNames ) { 
                public TableCellRenderer getCellRenderer( int row, int column ) {
                    return new PlusMinusCellRenderer();
                }
             };
    
            table.setRowHeight( 32 );
            showFrame( table );
        }
    
        private static void showFrame( JTable table ) {
            JFrame f = new JFrame("Custom Cell Renderer sample" );
            f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            f.add( new JScrollPane( table ) );
            f.pack();
            f.setVisible( true );
        }
    }
    
    class PlusMinusCellRenderer extends JPanel implements TableCellRenderer {
            public Component getTableCellRendererComponent(
                                final JTable table, Object value,
                                boolean isSelected, boolean hasFocus,
                                int row, int column) {
                    this.add( new JTextField( value.toString()  ) );
                    this.add( new JButton("+"));
                    this.add( new JButton("-"));
                    return this;
            }
    }
    

    Here’s a thread that may be interesting and here.

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

Sidebar

Related Questions

Hai guys, Is it possible to add multiple controls(Buttons) to PostBackTrigger's ControlId property inside
I used glade to create some gtk buttons. is it possible to add an
I'm trying to add share buttons to my simple website... Is it possible to
Is it somehow possible to customize or subclass System.Windows.Forms.ColorDialog to add a few buttons?
Is it possible to add a metadata-like description or comments to a table in
I have to add an unknown number of buttons to a form in WPF
Is it possible to have a ajax button inside email? I want to add
Is it possible to add an image to the buttons of the UIActionSheet as
Is it possible to add ui objects (buttons, text boxes etc) to a visible
Is it possible to add a custom tab to a project properties page in

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.