[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 465
  • Last Modified:

Text right-alignment in JTable

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
glogin
Asked:
glogin
  • 2
1 Solution
 
objectsCommented:
use a custom cell renderer for the column.

DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setHorizontalAlignment(SwingConstants.RIGHT);
0
 
CEHJCommented:
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
 
CEHJCommented:
8-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now