主题:[讨论]求教一个JOptionPane字体大小的问题
代码如下 请问为什么JOptionPane的默认字体没有更改
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class DefaultFontTest {
static {
try {
Font initFont = new Font("", Font.PLAIN, 16);
UIManager.put("OptionPane.font", initFont);
UIManager.put("Menu.font", initFont);
UIManager.put("MenuItem.font", initFont);
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {}
}
public DefaultFontTest() {
final JFrame frame = new JFrame();
Container con = frame.getContentPane();
con.setLayout(new BorderLayout());
JMenuBar mb = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem mi = new JMenuItem(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame, "显示OptionPane");
}
});
mi.setText("open");
mb.add(menu);
menu.add(mi);
frame.setJMenuBar(mb);
frame.setBounds(200, 200, 400, 300);
frame.setVisible(true);
}
public static void main(String[] args) {
new DefaultFontTest();
}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class DefaultFontTest {
static {
try {
Font initFont = new Font("", Font.PLAIN, 16);
UIManager.put("OptionPane.font", initFont);
UIManager.put("Menu.font", initFont);
UIManager.put("MenuItem.font", initFont);
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {}
}
public DefaultFontTest() {
final JFrame frame = new JFrame();
Container con = frame.getContentPane();
con.setLayout(new BorderLayout());
JMenuBar mb = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem mi = new JMenuItem(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(frame, "显示OptionPane");
}
});
mi.setText("open");
mb.add(menu);
menu.add(mi);
frame.setJMenuBar(mb);
frame.setBounds(200, 200, 400, 300);
frame.setVisible(true);
}
public static void main(String[] args) {
new DefaultFontTest();
}
}