Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 JTextPane,我正在尝试获取 JTextPane 的默认字体大小。
我曾尝试寻找诸如getFontSize()and之类的方法getTextSize(),但似乎都不存在。我显然错过了一些东西,所以有人可以帮忙吗?
getFontSize()
getTextSize()
我想你想要:
int size = yourTextPane.getFont().getSize();
或者更通用:
Font defaultFont = UIManager.getDefaults().getFont("TextPane.font"); int defaultSize = defaultFont.getSize();