[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Text right-alignment in JTable

Posted on 2004-09-17
3
Medium Priority
?
464 Views
Last Modified: 2008-02-20
hi all

by default, the text/number in the grid in JTable are left-aligned.

How to make the text is left-alignment while number is right-alignment?

Rgds/Glogin
0
Comment
Question by:glogin
[X]
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
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12089938
use a custom cell renderer for the column.

DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setHorizontalAlignment(SwingConstants.RIGHT);
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 12091035
You need to use a custom TableCellRenderer. See

http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#colorRenderer

and set the alignment as the second line of objects' code shows
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12122022
8-)
0

Featured Post

Industry Leaders: 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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

656 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