문제

I am am attempting to create a GUI to assist in playing a tabletop simulation game in Java. As part of that, I would need labels or some other form of text display that allows for a large font size for clarity. Is there a way to manipulate the size of text in a JLabel, or if not, is there another element that would allow me to do so. I could use images for each case, but I would rather not.

도움이 되었습니까?

해결책

You can use the .setFont method in a label, like so:

label = new JLabel("A label");
label.setFont(new Font("Serif", Font.PLAIN, 14));

다른 팁

There are a number of ways you might achieve this based on what it is you ultimately want to achieve.

For example, you could use...

Font font = ...
AffineTransformation at = AffineTransformation.getScaleInstance(2, 2);
font = font.deriveFont(at);

Which will double the font size...Don't forget to assign the resulting Font to the component you want to change ;)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top