Swing 中的什么字体在所有操作系统中看起来都一样? [英] What font in Swing looks the same in all OS?

查看:33
本文介绍了Swing 中的什么字体在所有操作系统中看起来都一样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 7 下使用 Netbeans 7.0 和 JDK6 来设计我的 Java 应用程序的用户界面.我应用系统外观.但它在 Windows 中看起来是我想要的,但在 MacOS 中有所不同,更糟糕的是,它在 Linux(LXDE、GNOME、KDE、XFCE)中的不同窗口管理器中看起来不同.

I use Netbeans 7.0 with JDK6 under Windows 7 to design the user interface of my Java application. I apply System look and feel. But it looks the way I want in Windows but differs in MacOS and even worse, it looks different in different window managers in Linux (LXDE, GNOME, KDE, XFCE).

我所说的不同是指字体的外观和大小.在 Windows 中,如果一个标签看起来是v 1.23",那么它在其他操作系统中看起来就像是v ...",因为该操作系统中的字体变大了,而 JLabel 没有足够的地方可以显示.这发生在几个地方.

By different I mean the fonts look and their size. In Windows, if a label looks "v 1.23", it looks like "v ..." in other OSes because the fonts become bigger in that OS and the JLabel do not have enough place to show. This happens in several places.

我不想增加标签宽度.我希望标签在所有操作系统中的给定宽度下看起来都一样.默认情况下,Netbeans 在我的电脑上使用 Tahoma 11pt 字体.我认为它并非在所有操作系统中都可用,因此其他操作系统使用不同的字体.

I don't want to increase the label width. I want the label to look the same in that given width in all OS. By default, Netbeans uses the font Tahoma 11pt on my pc. I think it's not available in all OSes so the other OSes use different font.

Arial 是一种常用字体吗?

Is Arial a common font?

我应该手动将每个元素的字体更改为 Arial 吗?或者有其他选择吗?

Should I change the font of every element to Arial manually? Or any other options?

推荐答案

说到窗口管理器,它不仅仅是字体大小,例如 gnome & 中两个控件之间的宽度处理方式不同.凯德.当涉及到在所有平台上使用相同的字体大小时,您可以使用 Sans Serif 字体,这在我使用过的所有操作系统中都可用.

When it comes to window managers there is a lot more to it than just font size, for instance the width between 2 controls are handled differently in gnome & KDE. when it comes down to using the same font size across all platforms you can use Sans Serif font, this is available in all the OS'es I've worked with.

它也会更好(如果您在要运行应用程序的操作系统中找不到衬线),您可以下载字体(来自 GNU 自由字体).

it would also be better (if you can't find serif in an OS where you want to run your app) you can download a font (free ones from GNU Free Fonts).

在设置字体大小时字体,为什么不尝试使用主题 &在那里设置字体...您可以使用 UIManager.setLookAndFeel() 方法来更改主题.这是关于 Look & 的链接感觉

when it comes to setting the font sizes & the fonts, why don't you try using a theme & set the font there... you can use the UIManager.setLookAndFeel() method to change themes. here is a link on Look & Feel

这篇关于Swing 中的什么字体在所有操作系统中看起来都一样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆