0

II have a Jtable and I am trying to centre align the text in the column headings. When I try and use the html center tags it seems to have no effect.

  Object[] columns = {"","<html><center>#<br>&nbsp;","<html><center>Type<br>&nbsp;",
        "<html><center>Shots<br>&nbsp;","<html><center>final<br>score","<html><center>Time<br>Played"};

Can you see what I am missing or suggest a simple alternative?

volican
  • 137
  • 1
  • 14
  • 1) `
    ` is deprecated. 2) Why do you have multiple `` tags? Is that something required by JTable? Because you would only have one opening and one closing HTML tag in a web page.
    – BSMP Dec 11 '15 at 02:02
  • Also, you need to close the `` tag. And yes, it has [been deprecated since HTML 4](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center). – Jia Jian Goi Dec 11 '15 at 02:04
  • Will it not even work in my own java app? – volican Dec 11 '15 at 02:08
  • Yes, `renderer.setHorizontalAlignment(JLabel.CENTER)` is shown in the [accepted answer](http://stackoverflow.com/a/7494597/230513). – trashgod Dec 11 '15 at 13:07

0 Answers0