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

Ask A Question

Stats

  • Questions 285k
  • Answers 285k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can do this by maintaining two stacks stack -… May 13, 2026 at 4:37 pm
  • Editorial Team
    Editorial Team added an answer This should work for you: mapper(Player, players_table, properties={'location'=relation(Location, uselist=False, backref=backref('players'))})… May 13, 2026 at 4:37 pm
  • Editorial Team
    Editorial Team added an answer Check the CakePHP manual if you are using $html->link correctly.… May 13, 2026 at 4:37 pm

Related Questions

Possible Duplicate: .Net Changes the element IDs I have the following problem (I'll explain
I have a QGroupBox with a couple of QRadioButtons inside of it and in
I'm trying to change a Button's Click property/event when a DataTrigger is triggered but
I have a set of controls inside a WindowsFormsHost and I would like to
I'm using this plugin: http://www.fyneworks.com/jquery/star-rating/ Is it possible to put a click function inside

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.