I have problems with setting the font of a JMenuBar
. I personally don't like the bold font Java frames use by default, so I tried to change it by using something like this:
public class MyFrame extends javax.swing.JFrame {
public MyFrame() {
JMenuBar menuBar = new JMenuBar();
menuBar.setFont(new Font("sans-serif", Font.PLAIN, 12));
setJMenuBar(menuBar);
setSize(600, 400);
// add some menus to the menu bar
menuBar.add(new JMenu("Foo"));
menuBar.add(new JMenu("Bar"));
menuBar.add(new JMenu("Baz"));
menuBar.add(new JMenu("Qux"));
setVisible(true);
}
}
As far as I know, the line menuBar.setFont(...)
sets the font used by the component menuBar. But when I instantiated one of these frames, the default font didn't change at all, not even when I put the font's size to 30.
I appreciate any help concerning this.