3

I created a simple application in Java swing. I developed this application in Windows OS. But when I moved this application to Linux, the Font sizes are giving big compared to Windows. How do I make a standard font size in all across the platform?

user414967
  • 5,225
  • 10
  • 40
  • 61
  • 1
    Font is one of taxatios for crossplatfom, Font is based on resources that came fron native os – mKorbel Sep 26 '12 at 11:12
  • Ok.Thanks. So how to make it standard font size? Because of this font size, texts ares cut off in the buttons. It is not visible properly. – user414967 Sep 26 '12 at 11:17
  • @user414967 Normally, if you used Swing features properly (especially LayoutManager's, and not force min/pref/max size), you shouldn't have much trouble of Cross-platform looks. – Guillaume Polet Sep 26 '12 at 11:20

2 Answers2

2

Let your chosen layout adapt to the host platform's default font by invoking pack() on the enclosing Window. Because pack() "causes this Window to be sized to fit the preferred size and layouts of its subcomponents," you won't have to worry about the different sizes. There are many good examples; here's a counter-example.

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
-2

You can install Microsoft fonts on your Linux system. Here is a blog post about that: How to Install Windows Fonts in Java on Linux.

Nick Mudge
  • 51
  • 1
  • 4