JListmyList = new JList (); Font myFont = myList.getFont(); System.out.println("The font used in the JList is " + myFont.getName());
JListThis example creates a new JList object and sets its font to a custom font (Arial, 12pt plain). It then retrieves the font using the getFont method and prints out the name of the font to the console. These examples make use of the javax.swing package library.myList = new JList (); Font myFont = new Font("Arial", Font.PLAIN, 12); myList.setFont(myFont); Font listFont = myList.getFont(); System.out.println("The font used in the JList is " + listFont.getName());