how to change font size of JOptionPane

前端 未结 2 1333
余生分开走
余生分开走 2021-01-25 19:53
import java.awt.ComponentOrientation;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing         


        
2条回答
  •  失恋的感觉
    2021-01-25 20:35

    If you want all JOptionPanes to have the same font style and size, you can change the property of the UIManager with:

    javax.swing.UIManager.put("OptionPane.font", new Font("yourFontName", Font.BOLD, 30));
    

    To get a list of the available font names, use the following snippet:

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    String[] fontNames = ge.getAvailableFontFamilyNames();
    
    for (int index = 0; index < fontNames.length; index++)
    {
         System.out.println(fontNames[index]);
    }
    

提交回复
热议问题