Solved

Center Alignment in JTable

Posted on 2006-06-28
2
4,144 Views
Last Modified: 2008-02-07

How can I align the values in a JTable in center
0
Comment
Question by:sree032397
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
jagadeesh_motamarri earned 500 total points
ID: 17007252
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
 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 17007254
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

822 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question