Hi, I'm trying to set custom fonts, I can do it without problem with this code:

InputStream is = this.getClass().getResourceAsStream("/src/someFontName.ttf");
        Font f=null;
        try {
            f = Font.createFont(Font.TRUETYPE_FONT,is).deriveFont(15f);
        } catch (FontFormatException ex) {
            Logger.getLogger(PanelLiquidacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(PanelLiquidacion.class.getName()).log(Level.SEVERE, null, ex);
        }
        txtPlace=new JTextField();txtPlace.setBounds(185,10,310,20);
        if(f!=null){
            txtPlace.setFont(f);
            lblPlace.setFont(f);
            txtPlace.setForeground(Color.DARK_GRAY);
        }

What I'm wondering is, can I set the font to all JTextFields, JLabel, and JTextPanes used in the program with a single method, or am I forced to do it this way?

UIManager.put (key, font);

rellated for

UIManager.put("Button.font", font);
UIManager.put("ToggleButton.font", font);
UIManager.put("RadioButton.font", font);
UIManager.put("CheckBox.font", font);
UIManager.put("ColorChooser.font", font);
UIManager.put("ComboBox.font", font);
UIManager.put("Label.font", font);
UIManager.put("List.font", font);
UIManager.put("MenuBar.font", font);
UIManager.put("MenuItem.font", font);
UIManager.put("RadioButtonMenuItem.font", font);
UIManager.put("CheckBoxMenuItem.font", font);
UIManager.put("Menu.font", font);
UIManager.put("PopupMenu.font", font);
UIManager.put("OptionPane.font", font);
UIManager.put("Panel.font", font);
UIManager.put("ProgressBar.font", font);
UIManager.put("ScrollPane.font", font);
UIManager.put("Viewport.font", font);
UIManager.put("TabbedPane.font", font);
UIManager.put("Table.font", font);
UIManager.put("TableHeader.font", font);
UIManager.put("TextField.font", font);
UIManager.put("PasswordField.font", font);
UIManager.put("TextArea.font", font);
UIManager.put("TextPane.font", font);
UIManager.put("EditorPane.font", font);
UIManager.put("TitledBorder.font", font);
UIManager.put("ToolBar.font", font);
UIManager.put("ToolTip.font", font);
UIManager.put("Tree.font", font);

maybe is around some loop for that

commented: Tested and it works :) +0

Thanks, that was what I was looking for

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.