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

The following examples show how to use java.awt.Component#getFont() . These examples are extracted from open source projects. 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
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
@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 Project: jdk8u-jdk   File: XTable.java    License: 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 Project: jdk8u60   File: XTable.java    License: 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 Project: Java8CN   File: TitledBorder.java    License: 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 6
@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 7
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    if (isTabularType) {
        comp.setFont(boldFont);
    }
}
 
Example 8
@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 9
@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 10
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
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 12
@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 13
Source Project: netbeans   File: JFXRunPanel.java    License: 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
@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 15
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    if (isTabularType) {
        comp.setFont(boldFont);
    }
}
 
Example 16
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
public void renderKey(String key,  Component comp) {
    if (normalFont == null) {
        normalFont = comp.getFont();
        boldFont = normalFont.deriveFont(Font.BOLD);
    }
    if (isTabularType) {
        comp.setFont(boldFont);
    }
}
 
Example 18
Source Project: netbeans   File: JFXRunPanel.java    License: 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 19
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 20
Source Project: JDKSourceCode1.8   File: TitledBorder.java    License: 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);
}