gpt4 book ai didi

java - 我想更改文本流或标签中的字体大小

转载 作者:太空宇宙 更新时间:2023-11-04 06:57:45 24 4
gpt4 key购买 nike

我正在实现多行标签图。

我有一个问题。

如何更改文本流的字体大小?

在更改字体数据的高度值之前,我尝试使用[textflow.setFont]方法。

使用此代码,Font tFont = m_Textflow.getFont();
FontData[] tFontDataList = tFont.getFontData();
tFontDataList[0].setHeight(aSize);
m_Textflow.setFont(new Font(null, tFontDataList[0]));

但这并不能正常工作,并且在头上留下了任何空间。

请帮帮我T^T

最佳答案

参见the Font API 。你会找到构造函数

Font(String name, int style, int size) -

Creates a new Font from the specified name, style and point size.

所以你可以做类似的事情

String family = textFlow.getFont().getFamily();
int style = textFlow.getFont().getStyle();
int theNewFontSize = 30;
textFlow.setFont(new Font(family, style, theNewFontSize));

关于java - 我想更改文本流或标签中的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22494233/

24 4 0