2

It looks like the OS is controlling the whole JFrame title bar. I tried using:

UIManager.setLookAndFeel()

To change the Look and Feel, but it doesn't seem to affect the title bar.

On my Windows machine the default is left aligned, but on my Linux machine it's centered, and somehow, I'd like to try to always show the title text left aligned.

I saw one example where they basically built every element of the title bar from scratch, and I'd rather not go there.

Is there any other way to do it?

Thanks!

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
user1572522
  • 569
  • 2
  • 11
  • 26
  • May be that [question](http://stackoverflow.com/questions/9662393/how-to-center-align-the-title-in-a-jframe) can help to you – alex2410 Nov 12 '13 at 06:50
  • I saw that, but that will only work if the OS is left aligning it and you add spaces to center it. I guess you could add spaces to the right of it, but you'd have to detect what it was defaulting to.. I'm trying to use something based on this now: getRootPane().setWindowDecorationStyle(JRootPane.FRAME); But it doesn't look all that great.. – user1572522 Nov 12 '13 at 16:30
  • @user1572522 Can you share your solution here? What a shame that such a simple thing can't be done in java. I've tried many things to no avail. Then i tried to change my linux OS to left align window titles, that is even more difficult. So much for the "platform independence"! My forms are much weirder when displayed in linux. I want to try your solution for this mission impossible before giving up. – Dia Sheikh Jun 24 '21 at 18:43

1 Answers1

2

If the L&F supports window decorations, you can use setWindowDecorationStyle(). A complete example is cited here in UIManager Defaults.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • 1
    Thanks for your replies. I ended up going back to what I was trying to do originally, but the text in a status bar at the bottom of the screen. I simplified my whole Layout and got it working. – user1572522 Nov 13 '13 at 05:25
  • This probably more useful in the context of your application. – trashgod Nov 13 '13 at 12:09