Solved

Center Alignment in JTable

Posted on 2006-06-28
2
4,126 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
Comment Utility
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
Comment Utility
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now