
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
Customize JTabbedPane Appearance in Java
To customize how a JTabbedPane looks, change its font style, font face, font size and the background and foreground colors.
Let’s say the following is the JTabbedPane −
JTabbedPane tabbedPane = new JTabbedPane();
Now, let us customize the above created JTabbedPane −
tabbedPane.setBackground(Color.orange); tabbedPane.setForeground(Color.white); Font font = new Font("Verdana", Font.CENTER_BASELINE, 18); tabbedPane.setFont(font);
The following is an example to customize JTabbedPane −
Example
package my; import javax.swing.*; import java.awt.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Technologies"); JTabbedPane tabbedPane = new JTabbedPane(); JPanel panel1, panel2, panel3, panel4, panel5; panel1 = new JPanel(); panel2 = new JPanel(); panel3 = new JPanel(); panel4 = new JPanel(); panel5 = new JPanel(); tabbedPane.addTab("Data Science", panel1); tabbedPane.addTab("Blockchain ", panel2); tabbedPane.addTab("PHP", panel3); tabbedPane.addTab("Matlab ", panel4); tabbedPane.addTab("Servlet", panel5); tabbedPane.setBackground(Color.orange); tabbedPane.setForeground(Color.white); Font font = new Font("Verdana", Font.CENTER_BASELINE, 18); tabbedPane.setFont(font); frame.add(tabbedPane); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(660,350); frame.setVisible(true); } }
Output
Advertisements