List of utility methods to do Swing Font
Vector | getMultiLineTextForBBox(JComponent comp, double bboxWth, String txt, Font font) get Multi Line Text For B Box int startPos = 0, currPos = 0; String origText = txt; Graphics2D g2d = (Graphics2D) comp.getGraphics(); Hashtable<TextAttribute, Object> fontAttrib = new Hashtable<TextAttribute, Object>(); fontAttrib.put(TextAttribute.FONT, font); Vector<String> multiLine = new Vector<String>(); while (true) { currPos = getText4BBox(g2d, txt, startPos, bboxWth, fontAttrib, true); ... |
void | increaseDefaultFont(float multiplier) increase Default Font for (Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value != null && value instanceof FontUIResource) { FontUIResource fontUIResource = (FontUIResource) value; UIManager.put(key, fontUIResource.deriveFont(fontUIResource.getSize() * multiplier)); |
void | initGlobalFont(Font font) init Global Font FontUIResource fontRes = new FontUIResource(font); for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) { UIManager.put(key, fontRes); |
void | installColorsAndFont(Component c, Color background, Color foreground, Font font) install Colors And Font installFont(c, font); installColors(c, background, foreground); |
void | installLargerDefaultFonts() install Larger Default Fonts System.setProperty("swing.plaf.metal.userFont", "Dialog-17"); System.setProperty("swing.plaf.metal.systemFont", "Dialog-17"); System.setProperty("swing.plaf.metal.controlFont", "Dialog-Bold-17"); |
void | listFonts() list Fonts Font current = getUIFont(); System.out.println("Current font: " + current); System.out.println("Available fonts: "); String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); for (int i = 0; i < fonts.length; i++) { System.out.println("\t" + fonts[i]); |
void | makeFontBold(JComponent c) make Font Bold Font font = c.getFont();
c.setFont(new Font(font.getName(), Font.BOLD, font.getSize()));
|
void | makeFontsPlain() Makes all UIDefaults with Bold fonts to Plain fonts. UIDefaults uiDefaults = UIManager.getDefaults(); Enumeration enum1 = uiDefaults.keys(); while (enum1.hasMoreElements()) { Object key = enum1.nextElement(); Object value = uiDefaults.get(key); if (value instanceof FontUIResource) { Font font = ((FontUIResource) value).deriveFont(Font.PLAIN); uiDefaults.put(key, new FontUIResource(font)); ... |
JEditorPane | makeHtmlPane(CharSequence text, Font font) Creates a JEditorPane that displays a message. JEditorPane pane = new JEditorPane(); pane.setContentType("text/html"); pane.setFont(font); if (text != null) { pane.setText(applyFont(text, font)); pane.setEditable(false); pane.setBorder(new EmptyBorder(0, 0, 0, 0)); ... |
JEditorPane | makePlainTextPane(String text, Font font) Creates a JEditorPane that displays a message. JEditorPane pane = new JEditorPane(); pane.setContentType("text/plain"); if (text != null) { pane.setText(text); pane.setFont(font); pane.setEditable(false); pane.setBorder(new EmptyBorder(0, 0, 0, 0)); ... |