Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, it is possible, although It won't be easy. </p> <p>You have to write your own custom <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#renderer" rel="nofollow noreferrer">cell renderer</a> and your own <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editor" rel="nofollow noreferrer">cell editor</a>. </p> <p>This is a sample I made in 5 minutes:</p> <p><img src="https://i.stack.imgur.com/JCpy5.png" alt="sample"></p> <p>It is far from perfect, but shows the concept. </p> <p>Here's the source code:</p> <pre><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; } } </code></pre> <p>Here's a thread that may be <a href="http://forums.sun.com/thread.jspa?threadID=680674" rel="nofollow noreferrer">interesting</a> and <a href="http://www.devx.com/getHelpOn/10MinuteSolution/20425" rel="nofollow noreferrer">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload