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.
Java で特定の文字の幅に使用されているピクセル数を調べる必要があります。たとえば、文字 '3' と '1' の幅はピクセル単位です。
何か案は?
stringWidthグラフィックス内には、次のように method を使用して答えを返すことができる FontMetrics があります。
stringWidth
FontMetrics metrics = g.getFontMetrics(font); int width = metrics.stringWidth("3");