Example usage for javax.swing.plaf FontUIResource getFontName

List of usage examples for javax.swing.plaf FontUIResource getFontName

Introduction

In this page you can find the example usage for javax.swing.plaf FontUIResource getFontName.

Prototype

public String getFontName() 

Source Link

Document

Returns the font face name of this Font .

Usage

From source file:ru.apertum.qsystem.client.forms.FAdmin.java

/**
     * @param args the command line arguments
     * @throws Exception//from  w w  w .j ava2 s  . c  o m
     */
    public static void main(String args[]) throws Exception {
        QLog.initial(args, 3);
        Locale.setDefault(Locales.getInstance().getLangCurrent());

        //?  ? , ? 
        final Thread tPager = new Thread(() -> {
            FAbout.loadVersionSt();
            String result = "";
            try {
                final URL url = new URL(PAGER_URL + "/qskyapi/getpagerdata?qsysver=" + FAbout.VERSION_);
                final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setRequestProperty("User-Agent", "Java bot");
                conn.connect();
                final int code = conn.getResponseCode();
                if (code == 200) {
                    try (BufferedReader in = new BufferedReader(
                            new InputStreamReader(conn.getInputStream(), "utf8"))) {
                        String inputLine;
                        while ((inputLine = in.readLine()) != null) {
                            result += inputLine;
                        }
                    }
                }
                conn.disconnect();
            } catch (Exception e) {
                System.err.println("Pager not enabled. " + e);
                return;
            }
            final Gson gson = GsonPool.getInstance().borrowGson();
            try {
                final Answer answer = gson.fromJson(result, Answer.class);
                forPager = answer;
                if (answer.getData().size() > 0) {
                    forPager.start();
                }
            } catch (Exception e) {
                System.err.println("Pager not enabled but working. " + e);
            } finally {
                GsonPool.getInstance().returnGson(gson);
            }
        });
        tPager.setDaemon(true);
        tPager.start();

        Uses.startSplash();
        //     plugins
        Uses.loadPlugins("./plugins/");
        //      ?.
        FLogin.logining(QUserList.getInstance(), null, true, 3, FLogin.LEVEL_ADMIN);
        Uses.showSplash();
        java.awt.EventQueue.invokeLater(() -> {
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager
                        .getInstalledLookAndFeels()) {
                    System.out.println(info.getName());
                    /*Metal Nimbus CDE/Motif Windows   Windows Classic  //GTK+*/
                    if ("Windows".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
                if ("/".equals(File.separator)) {
                    final FontUIResource f = new FontUIResource(new Font("Serif", Font.PLAIN, 10));
                    final Enumeration<Object> keys = UIManager.getDefaults().keys();
                    while (keys.hasMoreElements()) {
                        final Object key = keys.nextElement();
                        final Object value = UIManager.get(key);
                        if (value instanceof FontUIResource) {
                            final FontUIResource orig = (FontUIResource) value;
                            final Font font1 = new Font(f.getFontName(), orig.getStyle(), f.getSize());
                            UIManager.put(key, new FontUIResource(font1));
                        }
                    }
                }
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                    | UnsupportedLookAndFeelException ex) {
            }
            try {
                form = new FAdmin();
                if (forPager != null) {
                    forPager.showData(false);
                } else {
                    form.panelPager.setVisible(false);
                }
                form.setVisible(true);
            } catch (Exception ex) {
                QLog.l().logger().error(" ? ??  . ", ex);
            } finally {
                Uses.closeSplash();
            }
        });
    }

From source file:Main.java

public static void setLookAndFeel(int fontSize) throws Exception {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    UIDefaults defaults = UIManager.getDefaults();
    Enumeration<Object> keys = defaults.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();

        if ((key instanceof String) && (((String) key).endsWith(".font"))) {
            FontUIResource font = (FontUIResource) UIManager.get(key);
            defaults.put(key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize));
        }/*from w  ww  .j  av a  2  s  . c  om*/
    }
}

From source file:Main.java

/**
 * Code from http://stackoverflow.com/questions/1236231/managing-swing-ui-default-font-sizes-without-quaqua
 * @param fontSize/*w  w w  .  j a  v  a 2  s.  c o m*/
 */
public static void changeDefaultFontSize(int fontSize) {
    UIDefaults defaults = UIManager.getDefaults();
    // UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    Enumeration<Object> keys = defaults.keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if ((key instanceof String) && (((String) key).endsWith(".font"))) {
            FontUIResource font = (FontUIResource) UIManager.get(key);
            defaults.put(key, new FontUIResource(font.getFontName(), font.getStyle(), fontSize));
        }
    }
}

From source file:com.floreantpos.main.SetUpWindow.java

private void initializeFont() {
    java.util.Enumeration keys = UIManager.getDefaults().keys();
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        Object value = UIManager.get(key);

        if (value != null && value instanceof FontUIResource) {
            FontUIResource f = (FontUIResource) value;
            String fontName = f.getFontName();

            Font font = new Font(fontName, f.getStyle(), PosUIManager.getDefaultFontSize());
            UIManager.put(key, new FontUIResource(font));
        }//from   w w w . ja  v  a  2  s  .c  o m
    }
}