Java Mac OSX native本身是否尊重UIManager字体的变化? [英] Does Java Mac OSX native look and feel respect UIManager font changes?

查看:211
本文介绍了Java Mac OSX native本身是否尊重UIManager字体的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java小程序,唯一可以正常工作的外观是本机mac。我想使字体有点大,并尝试使用标准的UIManager方法UIManager.put(Label.font,new Font(Georgia,Font。 PLAIN,18));

这没有改变。当然,它不会抛出异常。



有没有人知道本机mac的外观是否忽略了这些?



我知道有特定的方法在Mac上控制不同的大小,但这似乎只是使他们更小。您可能无法使控件大于常规。

解决方案

它似乎可以在任何已安装的L& F的Mac OS X上工作。 / p>

附录:如果您在启动后尝试更改设置,请参阅 如何设置外观
$ b $ b

  public final class Laf {

public static void main(String [] args){
EventQueue.invokeLater(new Runnable() {

@Override
public void run(){
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
UIManager.put(Label.font,新的字体(格鲁吉亚,Font.PLAIN, 18));
f.add(new JLabel(Test));
f.pack();
f.setVisible(true);
}
});



public final class LafApplet extends JApplet {
$ b $ @Override
public void init(){
UIManager .put(Label.font,new Font(Georgia,Font.PLAIN,18));
this.add(new JLabel(Test));
}
}


I have a java applet and the only look and feel that works properly is the native mac one. I wanted to make the fonts a bit larger and tried using the standard UIManager methods

UIManager.put("Label.font", new Font("Georgia", Font.PLAIN, 18));

This produces no change. It does not throw an exception, of course.

Does anyone know if the native mac look and feel ignores these?

I know there are specific ways to make controls different sizes on mac but these only seem to make them smaller. You cannot make the controls larger than regular.

解决方案

It appears to work on Mac OS X with any installed L&F.

Addendum: If you are trying to change the setting after startup, see How to Set the Look and Feel under Changing the Look and Feel After Startup.

public final class Laf {

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                JFrame f = new JFrame();
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                UIManager.put("Label.font", new Font("Georgia", Font.PLAIN, 18));
                f.add(new JLabel("Test"));
                f.pack();
                f.setVisible(true);
            }
        });
    }
}

public final class LafApplet extends JApplet {

    @Override
    public void init() {
        UIManager.put("Label.font", new Font("Georgia", Font.PLAIN, 18));
        this.add(new JLabel("Test"));
    }
}

这篇关于Java Mac OSX native本身是否尊重UIManager字体的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆