Java Code Examples for java.awt.Component#getFont()

The following examples show how to use java.awt.Component#getFont() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XOpenTypeViewer.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Component prepareRenderer(TableCellRenderer renderer,
        int row, int column) {
    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }

    Object o = ((DefaultTableModel) getModel()).getValueAt(row, column);
    if (column == 0) {
        String key = o.toString();
        renderKey(key, comp);
    } else {
        if (isClickableElement(o)) {
            comp.setFont(boldFont);
        } else {
            comp.setFont(normalFont);
        }
    }

    return comp;
}
 
Example 2
Source File: XTable.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Component prepareRenderer(TableCellRenderer renderer,
                                 int row, int column) {
    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }

    if (column == VALUE_COLUMN && isAttributeViewable(row, VALUE_COLUMN)) {
        comp.setFont(boldFont);
    } else {
        comp.setFont(normalFont);
    }

    return comp;
}
 
Example 3
Source File: XTable.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Component prepareRenderer(TableCellRenderer renderer,
                                 int row, int column) {
    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }

    if (column == VALUE_COLUMN && isAttributeViewable(row, VALUE_COLUMN)) {
        comp.setFont(boldFont);
    } else {
        comp.setFont(normalFont);
    }

    return comp;
}
 
Example 4
Source File: XTable.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Component prepareRenderer(TableCellRenderer renderer,
                                 int row, int column) {
    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }

    if (column == VALUE_COLUMN && isAttributeViewable(row, VALUE_COLUMN)) {
        comp.setFont(boldFont);
    } else {
        comp.setFont(normalFont);
    }

    return comp;
}
 
Example 5
Source File: TitledBorder.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected Font getFont(Component c) {
    Font font = getTitleFont();
    if (font != null) {
        return font;
    }
    if (c != null) {
        font = c.getFont();
        if (font != null) {
            return font;
        }
    }
    return new Font(Font.DIALOG, Font.PLAIN, 12);
}
 
Example 6
Source File: TitledBorder.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
protected Font getFont(Component c) {
    Font font = getTitleFont();
    if (font != null) {
        return font;
    }
    if (c != null) {
        font = c.getFont();
        if (font != null) {
            return font;
        }
    }
    return new Font(Font.DIALOG, Font.PLAIN, 12);
}
 
Example 7
Source File: TitledBorder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected Font getFont(Component c) {
    Font font = getTitleFont();
    if (font != null) {
        return font;
    }
    if (c != null) {
        font = c.getFont();
        if (font != null) {
            return font;
        }
    }
    return new Font(Font.DIALOG, Font.PLAIN, 12);
}
 
Example 8
Source File: JFXRunPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void setEmphasizedFont(Component label, boolean emphasized) {
    Font basefont = label.getFont();
    if(emphasized) {
        label.setFont(basefont.deriveFont(Font.ITALIC));
    } else {
        label.setFont(basefont.deriveFont(Font.PLAIN));
    }
}
 
Example 9
Source File: XOpenTypeViewer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    if (isTabularType) {
        comp.setFont(boldFont);
    }
}
 
Example 10
Source File: XOpenTypeViewer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        italicFont = normalFont.deriveFont(Font.ITALIC);
    }
    for(Object k : type.getIndexNames()) {
        if(key.equals(k))
            comp.setFont(italicFont);
    }
}
 
Example 11
Source File: XOpenTypeViewer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    if (isTabularType) {
        comp.setFont(boldFont);
    }
}
 
Example 12
Source File: XMBeanNotifications.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized Component prepareRenderer(
        TableCellRenderer renderer, int row, int column) {
    //In case we have a repaint thread that is in the process of
    //repainting an obsolete table, just ignore the call.
    //It can happen when MBean selection is switched at a very quick rate
    if (row >= getRowCount()) {
        return null;
    }

    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    UserDataCell cell = getUserDataCell(row, 2);
    if (column == 2 && cell != null) {
        comp.setFont(boldFont);
        int size = cell.getHeight();
        if (size > 0) {
            if (getRowHeight(row) != size) {
                setRowHeight(row, size);
            }
        }
    } else {
        comp.setFont(normalFont);
    }

    return comp;
}
 
Example 13
Source File: JFXRunPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void setBoldFont(Component label, boolean bold) {
    Font basefont = label.getFont();
    if(bold) {
        label.setFont(basefont.deriveFont(Font.BOLD));
    } else {
        label.setFont(basefont.deriveFont(Font.PLAIN));
    }
}
 
Example 14
Source File: XOpenTypeViewer.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        italicFont = normalFont.deriveFont(Font.ITALIC);
    }
    for(Object k : type.getIndexNames()) {
        if(key.equals(k))
            comp.setFont(italicFont);
    }
}
 
Example 15
Source File: TitledBorder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected Font getFont(Component c) {
    Font font = getTitleFont();
    if (font != null) {
        return font;
    }
    if (c != null) {
        font = c.getFont();
        if (font != null) {
            return font;
        }
    }
    return new Font(Font.DIALOG, Font.PLAIN, 12);
}
 
Example 16
Source File: XOpenTypeViewer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        italicFont = normalFont.deriveFont(Font.ITALIC);
    }
    for(Object k : type.getIndexNames()) {
        if(key.equals(k))
            comp.setFont(italicFont);
    }
}
 
Example 17
Source File: XMBeanNotifications.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized Component prepareRenderer(
        TableCellRenderer renderer, int row, int column) {
    //In case we have a repaint thread that is in the process of
    //repainting an obsolete table, just ignore the call.
    //It can happen when MBean selection is switched at a very quick rate
    if (row >= getRowCount()) {
        return null;
    }

    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    UserDataCell cell = getUserDataCell(row, 2);
    if (column == 2 && cell != null) {
        comp.setFont(boldFont);
        int size = cell.getHeight();
        if (size > 0) {
            if (getRowHeight(row) != size) {
                setRowHeight(row, size);
            }
        }
    } else {
        comp.setFont(normalFont);
    }

    return comp;
}
 
Example 18
Source File: ExtractInlinedStylePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Component res = orig.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    if (value instanceof ReferedExternalStyleSheetItem) {
        if (res instanceof JLabel) {
            Font font = res.getFont();
            if (!font.isBold()) {
                res.setFont(font.deriveFont(Font.BOLD));
            }
        }
    }
    return res;
}
 
Example 19
Source File: XOpenTypeViewer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    if (isTabularType) {
        comp.setFont(boldFont);
    }
}
 
Example 20
Source File: XMBeanNotifications.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized Component prepareRenderer(
        TableCellRenderer renderer, int row, int column) {
    //In case we have a repaint thread that is in the process of
    //repainting an obsolete table, just ignore the call.
    //It can happen when MBean selection is switched at a very quick rate
    if (row >= getRowCount()) {
        return null;
    }

    Component comp = super.prepareRenderer(renderer, row, column);

    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    UserDataCell cell = getUserDataCell(row, 2);
    if (column == 2 && cell != null) {
        comp.setFont(boldFont);
        int size = cell.getHeight();
        if (size > 0) {
            if (getRowHeight(row) != size) {
                setRowHeight(row, size);
            }
        }
    } else {
        comp.setFont(normalFont);
    }

    return comp;
}