I have an application controlling hardware that has a JDialog displayed when the user wants 'backdoor' access to the hardware. That JDialog is filled with buttons and features and I don't want to increase its size, especially vertically. I do want to add a warning text so some new users will be warned not to play with the buttons, as doing the wrong thing can damage the hardware. Adding a dialog that the user has to dismiss is not an option.
There is space in the header I would like to use so I updated it to this:

This is cool, but I would like to emphasize it by coloring the warning text red like this:

I have tried using HTML tags which works in a JLabel, but the setTitle() method doesn't recognize them and just puts them into the header.
I though of using an icon, so I created a long rectangle with red text and called the setIconImage():

The icon is there but resized to fit a square. (Look at the upper left. I laughed, then sighed)
The only solution I could find searching the web is to create my own LookAndFeel, which I didn't want to get into, as it seems excessive for just a red text.
Is there a way to manipulate the text in a Title similar to what you can do to a JLabel?
In the past I have though about using that header space for often used controls but couldn't figure out how. For example, Microsoft Excel now has a Save icon and a Search Text Box up there on a spreadsheet. (Does Javafx have this feature?)
Источник: https://stackoverflow.com/questions/781 ... -title-bar
Мобильная версия