Setting application default font

I have tried to search the Sun Java site for detailed info on this but haven't got anywhere.
I have an application (Java 1.3) which will be hosted on a UNIX JVM, but displayed on a Windows2000 m/c. The only LookAndFeel available is the Metal one, and the default font is a rather chunky Dialog font.
I want a font more like the W2000 font (arial or helvetica I think).
Is it possible to change this in the UIManager/LookAndFeel?
I have seen some talk in similar threads about discovering font property keys, thne using these to ally a Font object to a certain class of component (e.g labels, panels etc).
Has anyone done anything similar, and if so can you please spell it out for me!
Kind regards,
Dave

I took a little bit from both of the examples and I put together a new class that allows the user to choose what font to apply to all or, individual components. I thought that it might be helpful to other people.
enjoy :)
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: NeoCore Inc</p>
* <p>Based on code by: Andrew Malcolm</p>
* @author Sandor Dornbush
* @version 1.0
package com.neocore.xmsApp;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import javax.swing.plaf.*;
public class PLAFTest extends JFrame {
JPanel main = new JPanel();
JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
JButton exampleButton = new JButton();
JPanel jPanel2 = new JPanel();
JScrollPane m_jScrollPaneFonts = new JScrollPane();
JList fontsList = new JList();
JButton applyButton = new JButton("Apply");
ButtonGroup buttonGroup1 = new ButtonGroup();
JRadioButton m_jRadioButtonPlain = new JRadioButton();
JRadioButton m_jRadioButtonBold = new JRadioButton();
JRadioButton m_jRadioButtonItalic = new JRadioButton();
JTextField m_jTextFieldSize = new JTextField();
JLabel jLabel2 = new JLabel();
private String[] components;
JList componentList = new JList();
public PLAFTest() {
try {
layoutComponents();
addActionListeners();
catch(Exception e) {
e.printStackTrace();
pack();
GraphicsEnvironment graphicsEnvironment=GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontNames=graphicsEnvironment.getAvailableFontFamilyNames();
fontsList.setListData(fontNames);
UIDefaults defaults = UIManager.getDefaults();
// Build of Map of attributes for each component
Enumeration enum = defaults.keys();
Vector v = new Vector();
v.add("All");
for(int i=1; enum.hasMoreElements(); i++) {
Object key = enum.nextElement();
String key_s = key.toString();
if(key_s.endsWith(".font") &&
!key_s.startsWith("class") &&
!key_s.startsWith("javax")) {
int index = key_s.indexOf(".font");
String s = key_s.substring(0,index);
v.add(s);
components = (String[]) v.toArray(new String[0]);
componentList.setListData(components);
m_jTextFieldSize.setText("12");
m_jRadioButtonPlain.setSelected(true);
void this_windowClosing(WindowEvent e) {
close();
void close() {
System.exit(0);
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
FontUIResource font=(FontUIResource)UIManager.get("TextField.font");
PLAFTest plafTest=new PLAFTest();
if( font.isPlain()) plafTest.setTitle("PLAF "+font.getFontName()+" "+font.getSize()+" PLAIN");
if( font.isBold()) plafTest.setTitle("PLAF "+font.getFontName()+" "+font.getSize()+" BOLD");
if( font.isItalic()) plafTest.setTitle("PLAF "+font.getFontName()+" "+font.getSize()+" ITALIC");
plafTest.show();
catch(Exception e) {
e.printStackTrace();
private void layoutComponents() {
JPanel content = (JPanel)getContentPane();
content.setLayout(new BorderLayout());
JPanel top = new JPanel(new GridLayout(1,3));
// pick the font
m_jScrollPaneFonts.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
m_jScrollPaneFonts.setBorder(BorderFactory.createTitledBorder("Choose Font:"));
top.add(m_jScrollPaneFonts);
m_jRadioButtonPlain.setText("Plain");
m_jRadioButtonBold.setText("Bold");
m_jRadioButtonItalic.setText("Italic");
// pick the component to apply it to
JScrollPane scrolls = new JScrollPane(componentList);
scrolls.setBorder(BorderFactory.createTitledBorder("Choose Component to Apply to:"));
top.add(scrolls);
// all of the example components
JPanel examples = new JPanel(new GridLayout(0,1));
jLabel1.setText("Label");
examples.add(jLabel1);
jTextField1.setText("TextField");
examples.add(jTextField1);
examples.add(exampleButton);
exampleButton.setText("Button");
examples.setBorder(BorderFactory.createEtchedBorder());
top.add(examples);
content.add(top,"Center");
// all the stuff on the bottom
JPanel bottom = new JPanel(new FlowLayout(FlowLayout.LEFT));
bottom.add(m_jRadioButtonItalic);
bottom.add(m_jRadioButtonBold);
bottom.add(m_jRadioButtonPlain);
bottom.add(applyButton);
bottom.add(jLabel2);
bottom.add(m_jTextFieldSize);
content.add(bottom,"South");
m_jScrollPaneFonts.getViewport().add(fontsList, null);
buttonGroup1.add(m_jRadioButtonItalic);
buttonGroup1.add(m_jRadioButtonBold);
buttonGroup1.add(m_jRadioButtonPlain);
private void addActionListeners() {
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
this_windowClosing(e);
applyButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
applyButtonActionPerformed(e);
void applyButtonActionPerformed(ActionEvent e) {
try {
Object o =fontsList.getSelectedValue();
if(o==null)
return;
String fontname=(String)o;
o = componentList.getSelectedValue();
if(o==null){
return;
String componentName = (String)o;
int fontsize=12;
try {
fontsize=Integer.parseInt(m_jTextFieldSize.getText());
} catch(Exception ex) {
ex.printStackTrace();
return;
int fontstyle=Font.PLAIN;
if(m_jRadioButtonPlain.isSelected()) {
fontstyle=Font.PLAIN;
else if(m_jRadioButtonBold.isSelected()) {
fontstyle=Font.BOLD;
else if(m_jRadioButtonItalic.isSelected()) {
fontstyle=Font.ITALIC;
FontUIResource font=new FontUIResource(fontname,fontstyle,fontsize);
if(componentName.equals("All")) {
for(int i=1; i<components.length; i++)
UIManager.put( components[i] + ".font",font);
} else {
UIManager.put( componentName + ".font",font);
switch(fontstyle) {
case Font.PLAIN: setTitle("PLAF "+fontname+" "+fontsize+" PLAIN"); break;
case Font.BOLD: setTitle("PLAF "+fontname+" "+fontsize+" BOLD"); break;
case Font.ITALIC: setTitle("PLAF "+fontname+" "+fontsize+" ITALIC"); break;
SwingUtilities.updateComponentTreeUI(this);
catch(Exception ex) {
ex.printStackTrace();
}

Similar Messages

  • How to set a default font

    Hiya!
    I'm making a flyer in inDesign and i want to set a default font to run throughout the document whenever i create a text box. I also want the font size to be set at 10pt all the time. Does anyone know how to do this?
    Also - i have a template for the flyer which includes a border and table.... i want to be able to open this as a template for each flyer, which i can then fill in with information. Is this possible?
    Any pointers would be super appreciated.
    thanks

    Just deselect any item in the document you are working on and set your font and other variables in the font window/bar. Thats all. If you wish to set a standard font for all new document, than close all documents and set the things. This works for almost everything.

  • Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Just a suggestion..........
    Download Thunderbird.  Easier to use when it comes to what you want to do w/your emails. 

  • How do I set a default Font in Muse

    Is there a way to set a default font in Muse

    Hey,
    Currently there's no UI for changing the default text or graphic attributes for newly created text frames or rectangles.
    Kind of a workaround would be to define a paragraph style and a graphic style that meets your requirements and apply it to each newly created text frame.
    Cheers,
    Cristian

  • How do I set the default font in Acrobat XI Pro?

    I would like to enquire how I can set a default font in Acrobat XI Pro.

    What exactly are you referring to? Generally there is no such thing, but some tools allow certain defaults to be set...
    Mylenium

  • Setting a default font

    I want to set a default font for my out going emails. However, when I go into preferences and select fonts and set the message font, it changes it for all income messages as well.
    Is there a way to set the font for outgoing emails to have a different default font than the messages I view in my mailboxes?
    thanks and Happy New Year!
    Michelle

    it seems this is not an option.

  • Apex 4.2 forms conversion error when set application defaults

    when use migration forms conversion and i want to set application defaults return the next error
    Unable to seed values ORA-06550: line 15, column 82: PL/SQL: ORA-00918: column ambiguously defined ORA-06550: line 9, column 3: PL/SQL: SQL Statement ignored
    ORA-06550: line 15, column 82: PL/SQL: ORA-00918: column ambiguously defined ORA-06550: line 9, column 3: PL/SQL: SQL Statement ignored

    Hi Daniel,
    This issue has already been identified, tracked with bug number *14683491*, and has been resolved in development. The fix will be available in our next release. In the meantime, you can still set Application Defaults using the option available in Application Builder. Navigate to Application Builder, and select the Application Builder Defaults option in the Tasks region to the right of the page, pg 4000:1500.
    Regards,
    Hilary

  • Setting the default font

    Hey,
    I was just wondering if there is a way to set the default font to whatever you want. It is especially frustrating for footnotes (no matter how many times you change the font of your footnotes, every subsequent footnote is created in the default Helvetica).
    I've looked around in Help and such but can't find any option to set the default font.
    Thank you!
    Jesse.

    Jessiah87 wrote:
    Hey,
    I was just wondering if there is a way to set the default font to whatever you want. It is especially frustrating for footnotes (no matter how many times you change the font of your footnotes, every subsequent footnote is created in the default Helvetica).
    I've looked around in Help and such but can't find any option to set the default font.
    I described several time ways to do that.
    It requires surgery in the index.xml file describing the used template.
    Assuming that the used template is Blank.template.
    Create a new document using it.
    Save it as my_Blank.pages.
    Using the scheme which I described many times, open its index.xml file.
    To do that I use the free TextWrangler.
    Search for "footnote" to reach this block of code :
    You see the entry spelled <sf:fontName/>
    Edit it as :
    <sf:fontName>
    <sf:string sfa:string="LucidaGrande"/>
    </sf:fontName>
    to get :
    Of course, you may use an other fontname.
    The rule is to use the official internal fontname.
    I already posted a long list of such names.
    Save the edited index.xml file
    If the original document contained a index.xml.gz file, remove it so that when you will open the doc it will be forced to use the edited index.
    Create a new document
    Leave it empty and save it as a custom template : my_Blank.template in the dedicated folder.
    Each time you will create a document starting from this template, the footnotes will be automatically created using LucidaGrande
    Some lines below the fontName descriptor is the fontSize one.
    The default one is :
    <sf:fontSize>
    <sf:number sfa:number="10" sfa:type="f"/>
    </sf:fontSize>
    You may edit it as
    <sf:fontSize>
    <sf:number sfa:number="9" sfa:type="f"/>
    </sf:fontSize>
    or an other integer value so the footnotes will default to this fontSize.
    Of course, double check what you do.
    When you will be satisfied of the result, maybe you will wish to edit the inthebox template.
    It may be done but it's an other story.
    Yvan KOENIG (VALLAURIS, France) dimanche 6 mars 2011 21:50:14

  • HT2509 Can I set a default font to all my emails on iCloud?

    How do I set a default font for all my outgoing emails on iCloud?

    G'day 5508,
    Some thoughts. Try System settings first (this may not be the culprit).
    System Preferences > Language and Region > Advanced > Currency > Australian Dollar
    I can only adjust the currency cell by cell, column by column page by page.
    Forgive my stupidity, but if the currency is a cell format in the template, can you select all currency cells at once, then change the currency? You will have to do this separately for each Table, but within a Table, you can select a range of cells. Quicker than cell by cell.
    Once you have reformatted the document that emerged from that template, save the document as a template with the same name to overwrite the old template.
    Hope this helps, mate.
    Regards,
    Ian.

  • Setting Application Defaults by admin

    I want to set application defaults for a planning application, such that, when a user logs into the application he sees what I have set as default.
    eg. Display Options - Thousands separator :comma
    I changed the Applicaiton Settings via Administration and set Thousand Separator:comma. (34,567.00)
    But when a new user logs into the application, he does not see the comma. Instead he sees 34567.00.
    He then has to go to File->Preferences->Planning and tick the check box 'Use Application Default'.
    What purpose does a 'default value' serve if the user has to make this change to see the default?
    Or am I doing this wrong?Is there another way such that a user does not have to do anything to see the comma in the values within forms?
    Thanks

    I tried the following two scenarios:
    1. create user from scratch.-testuser
    That user is getting the default values as set by admin.
    2. For a pre existing user -jsm,taken from the clients active directory,whose id had been provisioned to test the forms,the default settings are not getting applied.
    Both users are using the same application and have the same provisioning.
    So why is scenario 2 not picking up the correct default settings ?
    Could it be due to any of the reasons below?
    a. SHe tried setting her own user preferences at some point. Hence she has to manually select the 'use application default' to get the default settings.
    b. I changed the application default settings today to 'comma' and hence I have to restart planning services

  • CMDLET commands regarding setting a default font for all users using OWA on an exchange 2010 platform

    HI,
    We are running Exchange 2010 and are migrating users from 2003 to 2010 with no problems.  The client has asked me to set OWA font to LuidaSans which I can do for individuals with no problems.  However, when I try and run the following command
    Get-Mailbox -Resultsize Unlimited | Set-MailboxMessageConfiguration -LucidaSans but then got a message to state
    "property composefontname can't be set on this object becuase it requires the object to have version 0.1 <8.0.535.0> or later.  The object's currant version is 0.0 <6.5.6500.0>"
    What object is this reffered to?  Can anyone help please?
    Thanks
    Paul

    Hi,
    To set a default font for all users, you can use this command: -
    Get-Mailbox | Set-MailboxMessageConfiguration -DefaultFontName "Trebuchet"
    You can use any font style in place of “Trebuchet”.
    I hope this information will be helpful for you.
    Thanks and regards
    Ashish@S 
    Ashish@V

  • How do I set a default font?

    How do I set a default font that will be used every time I open a new table?  Now I get Helvetica Neue 10 pt.  I want Arial 13pt.

    F,
    Create a Template to be saved as a custom template in My Templates, then always choose to begin new spreadsheet documents with that template, in Preferences. Prior to saving this custom template, create a table with the font and other features to your liking, then Capture it for future use. Make that table the one that the template opens with, and when you add tables later, you may select that custom table, just as you would have chosen from the built-in optional table arrangements.
    Jerry

  • How can i set a default font for premiere cs6

    I am hoping to find a way to set a default font for cs6.  I work for a company where i need to use Meta book. Every time I create a new title/text slide, i have to change the font to meta book.  is there a way to make meta book the font that always comes up(as a default) when i go to create a new title/text
    thanks for the help(if there is any)

    You set up your font in the Title Properties then go the panel (dropdown) menu of the Title Styles and select New Style.

  • Set a default Font for a whole Swing application?

    Hi,
    Is it possible to set "Courier" as the default font for a whole swing application?
    I seem to have gotten lost here, could someone give me some pointers please?
    Thank You,
    -Uday

    So it needs to be done right at the beginningYes.
    Is there a code sample i can look at for reference and a standard way of doing this.I've seen examples posted in the forum the use the UIManager.getDefaults() method and then iterate through the defaults looking for all properties that end with ".font" and then replace the font as required.

  • How can I set the default font in tables

    I am using Pages "09 4.3.  I use Myriad in Table cells and have to change the font in about 6 cells in a table before Pages accepts that is the one to use.  I would like to be able to determine the default font in one operation when I first set the document up.  Does anyone know if this can be done and how please?

    Find out what the Paragraph Style is that is used in the table by selecting some text. Change it to what you want.
    Open the Styles Drawer > click on the red arrow next to the style > Update it > When you are finished save it as a Template
    Peter

Maybe you are looking for

  • Using JSPs to process text - use MockHttpServletRequest?

    I'd like to use a JSP file to define and render the body of an email message. I don't want to use this to process an actual Http request, but instead invoke it manually, get the output as a string and then send an email message using the string as th

  • The latest version of itunes (8.0) will not burn cds for me

    Ive been able to burn a few but the majority of the time Im just wasting cds. I click burn disc, insert blank disc, the mac then checks playlist. Then it says its writing playlist, but nothing happens. It sounds like the mac is working on it and when

  • Trouble with simple Query by Example

    Hey all, I am well aware that similar topics are all over the forums. I've exhausted myself fishing around for just the right thread. I am new to APEX. I have this book "Easy Oracle HTML-DB". It is somewhat helpful, but its examples are hard to follo

  • Displaying Keywords

    Can anybody please tell me if it is possible to display the keywords under the images when viewing them in Library? Thanks Caroline

  • QT not working on Windows

    I have some QT movies (only audio portions) that I need to use for a project. The PC I am working on will play the QT Files with the QT player, but they do NOT pay (or even show up (controller) in Director at all (both in the Director file and the Pr