Java Code Examples for java.awt.Component#setFont()
The following examples show how to use
java.awt.Component#setFont() .
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: XTable.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@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 2
Source File: XOpenTypeViewer.java From visualvm with GNU General Public License v2.0 | 6 votes |
@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); } 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 3
Source File: XTable.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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 jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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: XOpenTypeViewer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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 6
Source File: ResultSetCellRenderer.java From netbeans with Apache License 2.0 | 6 votes |
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Object resolvedValue; if(value instanceof SQLConstant) { resolvedValue = "<" + ((SQLConstant) value).toString() + ">"; } else { resolvedValue = value; } Component c = super.getTableCellRendererComponent(table, resolvedValue, isSelected, hasFocus, row, column); c.setFont(new Font(c.getFont().getFamily(), Font.ITALIC, 9)); ((JLabel) c).setToolTipText(resolvedValue.toString()); if (!isSelected) { c.setForeground(foregroundColor); } return c; }
Example 7
Source File: XOpenTypeViewer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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 8
Source File: XTable.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@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 9
Source File: XOpenTypeViewer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 10
Source File: XOpenTypeViewer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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 11
Source File: CapabilityTableCellEditor.java From arcusplatform with Apache License 2.0 | 5 votes |
@Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { AttributeDefinition definition = (AttributeDefinition) value; AttributeType type = definition.getType(); current = cache.get(type); if(current == null) { current = createNew(type); cache.put(type, current); } Component c = current.getTableCellEditorComponent(table, renderValue(value), isSelected, row, column); c.setFont(table.getFont()); return c; }
Example 12
Source File: XOpenTypeViewer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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 File: java_awt_Component.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override protected Component getObject() { Component component = new MyComponent(); component.setBackground(Color.WHITE); component.setFont(new Font(null, Font.BOLD, 5)); return component; }
Example 14
Source File: ProfileDialog.java From jeveassets with GNU General Public License v2.0 | 5 votes |
@Override public Component getListCellRendererComponent(JList<? extends Profile> list, Profile value, int index, boolean isSelected, boolean cellHasFocus) { Component component = renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value.isActiveProfile()) { Font font = component.getFont(); component.setFont(new Font(font.getName(), font.getStyle() + Font.BOLD, font.getSize())); } return component; }
Example 15
Source File: XOpenTypeViewer.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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 16
Source File: ViewHelper.java From FastCopy with Apache License 2.0 | 5 votes |
public static void setFontSize(List<Component> componetsList, int newFontSize) { //WalletSettings.getInstance().setFontSize(newFontSize); for (Component component : componetsList) { Font original = component.getFont(); Font newFont = original.deriveFont(Float.valueOf(newFontSize)); component.setFont(newFont); } }
Example 17
Source File: java_awt_Component.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override protected Component getObject() { Component component = new MyComponent(); component.setBackground(Color.WHITE); component.setFont(new Font(null, Font.BOLD, 5)); return component; }
Example 18
Source File: java_awt_Component.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override protected Component getAnotherObject() { Component component = new MyComponent(); component.setForeground(Color.BLACK); component.setFont(new Font(null, Font.ITALIC, 6)); return component; }
Example 19
Source File: CellRenderer.java From Carcassonne with Eclipse Public License 2.0 | 5 votes |
/** * @see javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, * boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (column == GameStatisticsGUI.SCORE_COLUMN) { component.setFont(component.getFont().deriveFont(Font.BOLD)); } component.setForeground(round.getPlayer(row).getColor().textColor()); component.setBackground(column == 0 ? GameStatisticsGUI.HEADER_COLOR : GameStatisticsGUI.BODY_COLOR); return component; }
Example 20
Source File: UnitTable.java From netbeans with Apache License 2.0 | 4 votes |
@Override public Component prepareRenderer (TableCellRenderer renderer, int rowIndex, int vColIndex) { if (rowIndex < 0 || vColIndex < 0) { return null; } Component c = super.prepareRenderer (renderer, rowIndex, vColIndex); Color bgColor = getBackground (); Color bgColorDarker = getDarkerColor(bgColor); Unit u = model.getUnitAtRow(convertRowIndexToModel(rowIndex)); if (u != null && !u.canBeMarked ()) { c.setForeground (Color.gray); } else { if (vColIndex == 1 && u != null && UpdateManager.TYPE.FEATURE.equals(u.updateUnit.getType())) { c.setFont(getFont().deriveFont(java.awt.Font.BOLD)); } else { c.setFont(getFont()); } if (isRowSelected(rowIndex)) { c.setForeground(getSelectionForeground()); } else { c.setForeground(getForeground()); } } if (!isCellSelected (rowIndex, vColIndex)) { if (rowIndex % 2 == 0 && !model.isExpansionControlAtRow(rowIndex)) { c.setBackground (bgColorDarker); } else { c.setBackground (bgColor); } } else if (model.isExpansionControlAtRow(rowIndex)) { c.setBackground (getBackground ()); c.setForeground(getForeground()); JComponent jc = (JComponent)c; jc.setBorder(BorderFactory.createEmptyBorder()); } int fontHeight = c.getFontMetrics(c.getFont()).getHeight(); if (rowHeight < 0 || rowHeight < fontHeight) { int def = new JTable().getRowHeight(); rowHeight = Math.max(def, fontHeight); setRowHeight(rowHeight); } return c; }