Highlighting/Making Bold Button Text

Highlighting/Making Bold Button Text

How do I highlight or make bold the text in a button or a list?

Java Buttons, Lists, Labels, TextAreas, Canvases, etc, are all subclasses ofthe Java Component class which in turn defines generic methods for modifyingthe look and feel of Java’s UI elements. The following are some of themethods in java.awt.Component that allow you to query or change acomponent’s appearance on the screen:

        getFont()        setFont()        getForeground()        setForeground()        getBackground()        setBackground()        
For example, the applet below constructs a row of buttons, some with alteredfonts, some with altered colors (to produce the high-lighted effect), and alist item with non-default fonts and colors:
import java.awt.*;import java.io.*;import java.applet.*;//// Create a number of buttons with different fonts and colors.//public class ButtonTest extends Applet {        public void init() {                Button b1 = new Button(“Normal”);                add(b1);                Button b2 = new Button(“Bold”);                b2.setFont(new Font(“TimesRoman”, Font.BOLD, 14));                add(b2);                Button b3 = new Button(“Italic”);                b3.setFont(new Font(“TimesRoman”, Font.ITALIC, 14));                add(b3);                Button b4 = new Button(“Bold-italic”);                b4.setFont(new Font(“TimesRoman”, Font.ITALIC + Font.BOLD, 14));                add(b4);                Button b5 = new Button(“High-lighted”);                b5.setForeground(Color.blue);                b5.setBackground(Color.yellow);                add(b5);                List l = new List(4, false);                l.setForeground(Color.black);                l.setBackground(Color.red);                l.setFont(new Font(“TimesRoman”, Font.ITALIC, 14));                l.addItem(“This is a test”);                l.addItem(“This is also a test”);                add(l);        }        //        // Defining a main() routine allows the applet to be        // run as a standalone java application        // using:  java ButtonTest        //        public static void main(String argv[]) {                Frame f = new Frame(“ButtonTest”);                Applet a = new ButtonTest();                a.init();                a.start();                f.setLayout(new BorderLayout());                f.add(“Center”, a);                f.pack();                f.show();        }}

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing