Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Center Alignment in JTable

Posted on 2006-06-28
2
4,152 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

860 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