1

I have an application which uses the default, metal, look and feel in Unix. For Solaris 10 this means the Dialog font is being translated as Arial. For Solaris 11 the font files have moved, so my font has changed. I cannot change any files except those in my application so changing fontconfig.properties is not an option.

1) Is there any way to say Dialog=Arial (and Dialog.Bold = Arial.Bold) in the beginning of the application?

2) Since I couldn't find a way to do the above I have been using the UIManager.put("Menu.font", new Font("Arial, Font.BOLD, 12)) commands. This seems to work (hopefully I don't miss a widget type) however my JTree, which is not using the Label.font when I use the defaults, is picking up my Label.font value when I call UIManager.put("Label.font", new Font("Arial, Font.BOLD, 12)). This happens even when I also have UIManager.put("Tree.font", new Font("Arial, Font.PLAIN, 12)).

Using the defaults my labels are bold and my tree is not. Do you have any suggestions about what could be happening with this and how I can separate the two fonts so that I can force them to be Arial but the Labels bold and the JTree plain?

Setting up the UI manager is the first thing that the application does.

Brant Olsen
  • 5,628
  • 5
  • 36
  • 53
Ric Holtz
  • 11
  • 4
  • Why does it matter that the logical font, `Dialog`, is mapped to a different physical font in Solaris 11? – trashgod Oct 06 '12 at 02:16
  • Having the fonts map differently means that the application does not look the same between the two systems. Some of the values in combo boxes or on buttons are being truncated since the font is now larger. Since this application is used by clients, not just by myself, the look of the application cannot change just because a client upgrades from Solaris 10 to Solaris 11. – Ric Holtz Oct 08 '12 at 14:17

1 Answers1

1

Some of the values in combo boxes or on buttons are being truncated, since the font is now larger.

Surely truncated text is an abomination, but adjusting Font sizes is not a solution. Instead, use a suitable layout and pack() the enclosing Window, which "Causes this Window to be sized to fit the preferred size and layouts of its subcomponents." This example compares the same program on several platforms, each of which has different physical fonts mapped to the default font families.

As this approach is rather general in nature, it may help to edit your question to include an sscce that exhibits the particular problem you are having.

See also Should I avoid the use of set[Preferred|Maximum|Minimum]Size methods in Java Swing?

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • This doesn't really answer the question. – FkYkko Oct 19 '15 at 11:32
  • @FkYkko: In what way does this not answer the question? – trashgod Oct 19 '15 at 11:53
  • The questions was "Using Java can I force the Dialog font to default to Arial?". This answer simply does not answer that question. No offence. Really. – FkYkko Mar 11 '16 at 12:30
  • @FkYkko: In this answer, I'm trying to suggest _not_ changing the font at all, mostly because I don't know the user's underlying problem. Reading closer, this may be related to the `TreeCellRenderer` that provides the `JLabel`. Please don't hesitate to add an alternate answer or ping me here if you pose a related question. – trashgod Mar 11 '16 at 12:52