Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Center Alignment in JTable

Posted on 2006-06-28
2
Medium Priority
?
4,177 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

886 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