Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the default font size of Java swing components [duplicate]

When doing Java JFrame design, I need to edit the font size and font type manually each time drag and drop from the Swing palette. The default font of Java Swing components is Tahoma 11 plain.

What I want is the font size and font type to be set to Tahoma 15 plain when I drag JTextfield and then JLabel. So I don’t need to change manually anymore.

like image 674
Pisces Avatar asked Jun 15 '13 09:06

Pisces


People also ask

How do I increase the font size of a swing label?

We change the Font Size parameter to change the size of the JLabel Font. The use of the Font() function is shown below: Object. setFont(new Font("Font-Style", Font-Weight, Font Size));

How do you change font size in Java?

You can't actually change the size of an existing Font object. The best way to achieve a similar effect is to use the deriveFont(size) method to create a new almost identical Font that is a different size.

What is the default text size in Java?

The default text size in browsers is 16px.


2 Answers

Adjusting the UIDefaults is one way. Another is to design a pluggable look & feel.

like image 124
Andrew Thompson Avatar answered Sep 22 '22 00:09

Andrew Thompson


This is not a netbeans platform problem. Use the UIManager class to set the Font for the whole program. Hope these links will help you.

Setting the Default Font of Swing Program

Setting the Global Font for a Java Application

like image 31
Sithum Avatar answered Sep 19 '22 00:09

Sithum