List of usage examples for java.awt Font getFontName
public String getFontName()
From source file:MainClass.java
public static void main(String[] a) { GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); // Get the fonts for (Font f : fonts) { System.out.println(f.getFontName()); }//from w ww .j ava2 s . c om }
From source file:ComponentHier.java
public static void main(String args[]) { JFrame frame = new JFrame("JComponent Hierarchy"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font font = (Font) UIManager.get("Tree.font"); font = new Font(font.getFontName(), Font.BOLD, font.getSize() - 3); UIManager.put("Tree.font", font); Vector jEditorPaneVector = new NamedVector("JEditorPane", new Object[] { "JTextPane" }); Vector jTextFieldVector = new NamedVector("JTextField", new Object[] { "JPasswordField" }); Vector jTextComponentVector = new NamedVector("JTextComponent", new Object[] { jEditorPaneVector, "JTextArea", jTextFieldVector }); Vector jLayeredPaneVector = new NamedVector("JLayeredPane", new Object[] { "JDesktopPane" }); Vector jToggleButtonVector = new NamedVector("JToggleButton", new Object[] { "JCheckBox", "JRadioButton" }); Vector jMenuItemVector = new NamedVector("JMenuItem", new Object[] { "JCheckBoxMenuItem", "JMenu", "JRadioButtonMenuItem" }); Vector abstractButtonVector = new NamedVector("Abstract Button", new Object[] { "JButton", jMenuItemVector, jToggleButtonVector }); Object jComponentNodes[] = { abstractButtonVector, "JColorChooser", "JComboBox", "JFileChooser", "JInternalFrame", "JLabel", jLayeredPaneVector, "JList", "JMenuBar", "JOptionPane", "JPanel", "JPopupMenu", "JProgressBar", "JRootPane", "JScrollBar", "JScrollPane", "JSeparator", "JSlider", "JSplitPane", "JTabbedPane", "JTable", jTextComponentVector, "JToolBar", "JTree", "JViewPort" }; Vector jComponentVector = new NamedVector("JComponent", jComponentNodes); Object rootNodes[] = { jComponentVector }; Vector rootVector = new NamedVector("Root", rootNodes); JTree tree = new JTree(rootVector); tree.putClientProperty("JTree.lineStyle", "Angled"); JScrollPane scrollPane = new JScrollPane(tree); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); frame.setSize(250, 480);//ww w . ja v a 2s .com frame.setVisible(true); }
From source file:org.lobzik.home_sapiens.pi.BoxRegistrator.java
/** * @param args the command line arguments *///from w ww. jav a 2 s . c o m public static void main(String[] args) { // TODO code application logic here try { /* if (BoxCommonData.BOX_ID > 0) { System.err.println("Box registered already, " + BoxCommonData.BOX_ID_FILE + " exists. Exiting."); return; } JSONObject boxJson = new JSONObject(); boxJson.put("ssid", BoxCommonData.SSID); boxJson.put("public_key", new String(Files.readAllBytes(Paths.get(BoxCommonData.PUBLIC_KEY_FILE)), "UTF-8")); boxJson.put("version", BoxCommonData.BOX_VERSION); boxJson.put("wpa_psk", BoxCommonData.WPA_PSK); JSONObject reqJson = new JSONObject(); reqJson.put("action", "register_request"); reqJson.put("box_data", boxJson); URL url = new URL(BoxCommonData.REGISTER_SERVER_URL); URLConnection conn = url.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream()); out.write(reqJson.toString()); out.close(); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String decodedString; StringBuffer sb = new StringBuffer(); while ((decodedString = in.readLine()) != null) { sb.append(decodedString); } in.close(); JSONObject response = new JSONObject(sb.toString()); if (response.has("register_result") && response.getString("register_result").equals("success")) { int id = response.getInt("box_id"); File boxIdFile = new File(BoxCommonData.BOX_ID_FILE); FileOutputStream fos = new FileOutputStream(boxIdFile); OutputStreamWriter idFileOs = new OutputStreamWriter(fos); idFileOs.write("box_id=" + id + "\n"); idFileOs.flush(); idFileOs.close(); fos.flush(); fos.close(); System.out.println("Box registered successfully"); System.out.println("Box ID: " + id); System.out.println("Box SSID: " + BoxCommonData.SSID); System.out.println("Box WPA_PSK: " + BoxCommonData.WPA_PSK); //print on a sticker System.out.println("Box RSA public key: " + BoxCommonData.PUBLIC_KEY); System.out.println("Box registration done"); } else { System.err.println("Error while registering device "); System.err.println(sb.toString()); } //boxIdFile. */ GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); // Get the fonts for (Font f : fonts) { System.out.println(f.getFontName()); } } catch (Throwable e) { System.err.println("Error while registering device "); e.printStackTrace(); } }
From source file:Main.java
/** * Made font bold for the specified component * * @param comp swing component// ww w . j av a 2 s . c o m * @return component itself */ public static <T extends JComponent> T boldify(T comp) { Font font = comp.getFont(); Font boldFont = new Font(font.getFontName(), Font.BOLD, font.getSize()); comp.setFont(boldFont); return comp; }
From source file:au.org.ala.delta.editor.EditorPreferences.java
public static void setPreferredFont(Font font) { Preferences prefs = Preferences.userNodeForPackage(DeltaEditor.class); if (prefs != null) { prefs.put(FONT_KEY, font.getFontName() + "-" + font.getStyle() + "-" + font.getSize()); }//from ww w.ja v a 2s . c om }
From source file:org.apache.pdfbox.pdmodel.font.FontManager.java
/** * Get the standard font from the environment, usually Arial or Times New Roman. * * @return The standard font //from ww w . j av a2 s . com * */ public static java.awt.Font getStandardFont() { Font awtFont = getAwtFont(standardFont); if (awtFont == null) { // PDFBOX-1069 LOG.error("Standard font '" + standardFont + "' is not part of the environment"); LOG.error("Available fonts:"); for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) { LOG.error("\t" + font.getFontName()); } } return awtFont; }
From source file:ca.sqlpower.wabit.dao.session.FontConverter.java
public String convertToSimpleType(Font convertFrom, Object... additionalInfo) { StringBuffer buffer = new StringBuffer(); buffer.append(convertToStandardFontName(convertFrom.getFontName())); buffer.append("-"); buffer.append(FontStyle.getStyleByValue(convertFrom.getStyle()).getEncodedName()); buffer.append("-"); buffer.append(convertFrom.getSize()); return buffer.toString(); }
From source file:com.alkacon.opencms.formgenerator.CmsCaptchaEngine.java
/** * Filters the fonts available on the system. <p> * // ww w . j av a 2s . c o m * Only fonts, which start with one of the provided prefix are returned. * These prefix list ensures, that font do not contain unreadable characters. * * @param prefixList the list of prefix to filter the system fonts * * @return an array of standard fonts */ private Font[] getFilteredFonts(List<String> prefixList) { LOG.debug(Messages.get().getBundle().key(Messages.DEBUG_CAPTCHA_FONT_FILTERING_START_0)); List<Font> filteredFontsList = new LinkedList<Font>(); // Get all system fonts GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] systemFonts = e.getAllFonts(); for (Font f : systemFonts) { for (String prefix : prefixList) { if (f.getFontName().toLowerCase().startsWith(prefix.toLowerCase())) { filteredFontsList.add(f); LOG.debug(Messages.get().getBundle().key(Messages.DEBUG_CAPTCHA_ADD_FONT_1, f.getFontName())); } } } Font[] filteredFonts = new Font[filteredFontsList.size()]; int i = 0; for (Font f : filteredFontsList) { filteredFonts[i] = f; i++; } LOG.debug(Messages.get().getBundle().key(Messages.DEBUG_CAPTCHA_FONT_FILTERING_FINISH_1, Integer.valueOf(filteredFonts.length))); return filteredFonts; }
From source file:org.tellervo.desktop.prefs.Prefs.java
/** * Code a font into a string//w w w. j a va 2s. c om * * @param f * @return */ public static final String stringifyFont(Font f) { StringBuffer sb = new StringBuffer(); sb.append(f.getFontName()); sb.append('-'); int s = sb.length(); if ((f.getStyle() & Font.BOLD) != 0) { sb.append("BOLD"); } if ((f.getStyle() & Font.ITALIC) != 0) { sb.append("ITALIC"); } if (sb.length() > s) { sb.append('-'); } sb.append(f.getSize()); return sb.toString(); }
From source file:com.floreantpos.config.ui.TerminalConfigurationView.java
private void initializeFontConfig() { GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); // Get the fonts DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) cbFonts.getModel(); model.addElement("<select>"); //$NON-NLS-1$ for (Font f : fonts) { model.addElement(f.getFontName()); }//from w w w. j ava2 s.com String uiDefaultFont = TerminalConfig.getUiDefaultFont(); if (StringUtils.isNotEmpty(uiDefaultFont)) { cbFonts.setSelectedItem(uiDefaultFont); } }