Hi Marcus,

There are two possibilities.

1. Go to the topmost container and setFont on each contained component
recursively.

2. On the client (in a ULC client launcher), set font at the L&F level as
shown in the snippet below.

Thanks and regards,

Janak

>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] Behalf Of
>[EMAIL PROTECTED]
>Sent: Wednesday, October 10, 2007 2:03 PM
>To: [email protected]
>Subject: [ULC-developer] property to set fontsize applicationwide
>
>
>
>Hi,
>
>I just wanted to ask if there is a possibility to centrally set
>the font(-size) of all e.g. labels, buttons,.. applicationwide.
>Is there a property maybe so that I can switch between a small
>size and a larger size?
>
>Thanks a lot.
>
>Freundliche Grüße / Best Regards
>
>Marcus Langer
>DACHSER GmbH & Co. KG
>HN Kempten/ IT-Zentrale
-------------------------------------------

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCLabel;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTextArea;
import com.ulcjava.base.application.ULCTextField;
import com.ulcjava.base.development.DevelopmentRunner;

import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource;

import java.awt.BorderLayout;
import java.awt.Font;

public class ULCFontChangeExample extends AbstractApplication {

    public void start() {
        ULCFrame frame = new ULCFrame("Test");
        frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);

        ULCBoxPane box = new ULCBoxPane(true);
        box.add(new ULCLabel("Text test Label"));
        box.add(new ULCTextField("Text Test TextField"));
        ULCTextArea ta = new ULCTextArea(4, 40);
        ta.setText("A longer string of text\n with a couple\n of line
returns");
        box.add(new ULCScrollPane(ta));
        ULCButton btn = new ULCButton("Button");
        box.add(btn);
        frame.getContentPane().add(box, BorderLayout.CENTER);
        frame.setVisible(true);
    }

    public static void main(String[] a) {

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName
());
            adjustFont(10);
        } catch (Exception e) {
            e.printStackTrace();
        }
        DevelopmentRunner.setApplicationClass(ULCFontChangeExample.class);
        DevelopmentRunner.run();
    }

    public static void adjustFont(int adjust) {
        Object[] objs =
UIManager.getLookAndFeel().getDefaults().keySet().toArray();
        for (int i = 0; i < objs.length; i++) {
            if (objs[i].toString().toUpperCase().indexOf(".FONT") != -1) {
                Font font = UIManager.getFont(objs[i]);
                font = font.deriveFont((float)(font.getSize() + adjust));
                UIManager.put(objs[i], new FontUIResource(font));
            }
        }
    }
}

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to