title: JTabel Individual Cell Text Alignment
body: <p>Basically I have a <code>JTable</code>, and this <code>JTabel</code> will have a product in one cell, and then in the cell directly below it the cost.</p>
  
  <p>The product name should be aligned to the left.
  The product cost should be aligned to the right.</p>
  
  <p>I don't actually care what the alignment of other cells in each row is.</p>
  
  <p>So I need to set the alignment of either individual cells, or individual rows.  I've found ways to set the alignment of the table, and ways to set the alignment of the columns, but never the rows/individual cells.</p>
  
  <p><strong>sscce</strong>:</p>
  
  <pre><code>public class Main extends JFrame{
      public static void main(String args[]){
          new Main();
      }
      public Main(){
          super("Demo");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setExtendedState(MAXIMIZED_BOTH);
          setVisible(true);
          setLayout(new BorderLayout());
          TableModel dataModel = new AbstractTableModel() {
               Object rows[] = new Object[50];
               public int getColumnCount(){return 1;}
               public int getRowCount(){return rows.length;}
               public Object getValueAt(int row, int col){ 
                   return rows[row];
               }
               public boolean isCellEditable(int row, int col){
                   return false; 
               }
               public void setValueAt(Object value, int row, int col) {
                   rows[row] = value;
                   fireTableCellUpdated(row,0);
               }
           };
  
          JTable receipt = new JTable(dataModel);
          receipt.setBorder(BorderFactory.createEtchedBorder());
          receipt.setShowGrid(false);
          add(receipt,BorderLayout.CENTER);
          for(int i = 0; i &lt; 10; i+=2){
              receipt.setValueAt("ProductNameHere",i,0);
              receipt.setValueAt("Cost",i+1,0);
          }
          validate();
          repaint();
      }
  }
  </code></pre>