Solved

Text right-alignment in JTable

Posted on 2004-09-17
3
445 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
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
use a custom cell renderer for the column.

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

Accepted Solution

by:
CEHJ earned 50 total points
Comment Utility
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
Comment Utility
8-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
hash value 2 38
parentbit challenge 3 51
Passing list of object to Oracle Database Procedure 3 41
wordappend challenge 8 84
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.

772 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

9 Experts available now in Live!

Get 1:1 Help Now