• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4178
  • Last Modified:

Center Alignment in JTable


How can I align the values in a JTable in center
0
sree032397
Asked:
sree032397
  • 2
1 Solution
 
jagadeesh_motamarriCommented:
ok....try this


DefaultTableCellRenderer r = new DefaultTableCellRenderer();
r.setHorizontalAlignment(alignment);
t.getColumnModel().getColumn(col).setCellRenderer(r);


where alignement in 2nd line can be  JLabel.LEFT, JLabel.RIGHT etc

and

t is any JTable object.

col is the column for which you want the alignment to be.


___Jags.
0
 
jagadeesh_motamarriCommented:
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now