Java Swing TitledBorder formatTitle(TitledBorder titledBorder)

Here you can find the source of formatTitle(TitledBorder titledBorder)

Description

Formats the title of a given TitledBorder

Workaround for Java Bug ID: 7022041

License

Open Source License

Parameter

Parameter Description
titledBorder a TitledBorder

Return

the given TitledBorder with a formatted title

Declaration

public static TitledBorder formatTitle(TitledBorder titledBorder) 

Method Source Code

//package com.java2s;
import java.awt.Font;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;

public class Main {
    /**/*w w  w . ja  va2 s  .  c  om*/
     * Formats the title of a given TitledBorder
     * <p>
     * Workaround for Java Bug ID: 7022041
     * </p>
     * 
     * @param titledBorder
     *            a TitledBorder
     * @return the given TitledBorder with a formatted title
     */
    public static TitledBorder formatTitle(TitledBorder titledBorder) {
        Font titleBorderFont = UIManager.getDefaults().getFont(
                "TitledBorder.font");
        if (titleBorderFont != null) {
            titledBorder.setTitleFont(new Font(titleBorderFont.getName(),
                    Font.BOLD, titleBorderFont.getSize()));
        }

        return titledBorder;
    }
}

Related

  1. createTitledBorder(String name)
  2. createTitledBorder(String title)
  3. createTitledBorder(String title)
  4. CreateTitledBorderwMargin(String title, int topMargin, int leftMargin, int bottomMargin, int rightMargin)
  5. createTitledPanelBorder(String title)
  6. getBorder(String title)
  7. getBorderInsetsForNoComponent(Border border)
  8. getCompoundBorder(String text)
  9. getTitledBorderHeight(Border border)