0

In a JTable, is possibile to have the text of header on 2 or more lines?

Something like this:

enter image description here

I tried something like:

getModel().getColumn(i).setHeaderValue("first word" + "\n" + "Second word"); 

but what I get is this:

enter image description here

MDP
  • 4,177
  • 21
  • 63
  • 119
  • 1
    A wild guess: Usually, Swing support HTML (not sure whether it works for JTable headers as expected, though), so you might try `"first word
    Second word"`. If it doesn't work, drop a note, then there are probably other options.
    – Marco13 Jun 01 '19 at 09:40
  • @Marco13 thank you man, I didn't know it (this is the first time I workwith Swing). You really helped me :) – MDP Jun 01 '19 at 09:53
  • 1
    So then I think the other question covers this pretty well. Closing as a duplicate. Drop me a note if you think this is not OK: – Marco13 Jun 01 '19 at 10:08
  • In case someone had my same problem: according to what another user told me, swing has the HTML 3.2 engine, so I used a (because I had to force every line not to break), with
    .
    – MDP Jun 08 '19 at 12:35

0 Answers0