• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

align text center in JTable.

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
i want to align the text centei JTable cells how can i perform that.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To achieve what you are looking for, use cell renderer for your table. Use the interface TableCellRenderer.
In the interface you have a method "getTableCellRendererComponent" method which has various parameters. This renderer extends JLabel. You have to pass your cell to this renderer and it will be converted to JLabel. Use the SwingConstants.setHorizontalAlignment(CENTER) to display your text at the center of the cell.
Hope you are able to follow the flow.
regards
 
reply
    Bookmark Topic Watch Topic
  • New Topic