hehe,UIManager改改缺生的字体设置就可以啦,从BOLD改到PLAIN,不知为什么,粗体字总显示不好

解决方案 »

  1.   

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;public class SamplePopup {
      public static void main(String args[]) {    JFrame frame = new JFrame("Sample Popup");
        JButton button = new JButton ("Ask");
        Font f = new Font("Monospaced", Font.BOLD, 24);
        UIManager.put("Label.font", f);
        ActionListener actionListener = new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            Component source = (Component)actionEvent.getSource();
            Object response = JOptionPane.showInputDialog(
              source, 
              "Where would you like to go to lunch?",
              "Select a Destination", 
              JOptionPane.QUESTION_MESSAGE,
              null,
              new String[] {
                "Burger King", 
                "McDonalds", 
                "Pizza Hut", 
                "Taco Bell", 
                "Wendy's"},
              "McDonalds");
            System.out.println ("Response: " + response);
          }
        };
        button.addActionListener(actionListener);
        Container contentPane = frame.getContentPane();
        contentPane.add(button, BorderLayout.SOUTH);
        frame.setSize(300, 200);
        frame.setVisible(true);
      }
    }