
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Change JLabel Font in Java
To change JLabel font, use the setFont() method −
JLabel lable = label.setFont(new Font("Verdana", Font.PLAIN, 18));
Example
package my; import java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Label Example"); JLabel label; label = new JLabel("First Label"); label.setBounds(50, 50, 100, 30); label.setFont(new Font("Verdana", Font.PLAIN, 18)); frame.add(label); frame.setSize(300,300); frame.setLayout(null); frame.setVisible(true); } }
Output
Advertisements