List of utility methods to do Swing Font Set
int | getCharsWidth(Font font, char[] chars, int offset, int length) Gets the width of the specified char array. if (chars == null) { return 0; FontMetrics metrics = HELPER_LABEL.getFontMetrics(font); return metrics.charsWidth(chars, offset, length); |
Font | getFont(AttributeSet a) get Font StringBuffer buffer = new StringBuffer(StyleConstants.getFontFamily(a)); buffer.append('-'); if (StyleConstants.isBold(a)) { if (StyleConstants.isItalic(a)) { buffer.append("BOLDITALIC"); } else { buffer.append("BOLD"); } else if (StyleConstants.isItalic(a)) { buffer.append("ITALIC"); } else { buffer.append("PLAIN"); buffer.append('-').append(StyleConstants.getFontSize(a)); Font f = Font.decode(buffer.toString()); return f; |
void | increaseLabelFont(JLabel label, int offset) Modifica fontul de la un label si il face mai mare Font oldFont = label.getFont(); label.setFont(oldFont.deriveFont(oldFont.getStyle(), oldFont.getSize() + offset)); |
void | initGlobalFontSetting() init Global Font Setting Font font = new Font("SansSerif", Font.TRUETYPE_FONT, 12); FontUIResource fontRes = new javax.swing.plaf.FontUIResource(font); Enumeration<Object> keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof javax.swing.plaf.FontUIResource) UIManager.put(key, fontRes); ... |
void | setAntiAlisingFont() set Anti Alising Font System.setProperty("awt.useSystemAAFontSettings", "lcd"); System.setProperty("swing.aatext", "true"); |
void | setBorderFromFont(JComponent c) set Border From Font FontMetrics metrics = c.getFontMetrics(c.getFont()); int top = metrics.getDescent(); int left = metrics.charWidth(' '); c.setBorder(BorderFactory.createEmptyBorder(top, left, top, left)); |
void | setComponentsFont(Container container, Font font) set Components Font Component[] components = container.getComponents(); container.setFont(font); for (Component component : components) { component.setFont(font); if (component instanceof JMenu) { setComponentsFont((Container) component, font); |
void | setDefaultFont(final Font font) set Default Font UIDefaults uiDefaults = UIManager.getDefaults(); uiDefaults.put("TabbedPane.font", font); uiDefaults.put("Button.font", font); uiDefaults.put("List.font", font); uiDefaults.put("PasswordField.font", font); uiDefaults.put("TableHeader.font", font); uiDefaults.put("Table.font", font); uiDefaults.put("ToggleButton.font", font); ... |
void | setDefaultFont(Font font) set Default Font FontUIResource fontUIResource = new FontUIResource(font); for (java.util.Map.Entry<?, ?> entry : UIManager.getDefaults().entrySet()) { if (entry.getKey().toString().toLowerCase().endsWith("font")) { UIManager.put(entry.getKey(), fontUIResource); |
void | setDefaultFont(java.awt.Font font) set Default Font setDefaultFontResource(new javax.swing.plaf.FontUIResource(font));
|