importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassMainextendsJPanel{String[] type ={"Serif","SansSerif"};int[] styles ={Font.PLAIN,Font.ITALIC,Font.BOLD,Font.ITALIC +Font.BOLD };String[] stylenames ={"Plain","Italic","Bold","Bold & Italic"};publicvoidpaint(Graphics g){for(int f =0; f < type.length; f++){for(int s =0; s < styles.length; s++){Font font =newFont(type[f], styles[s],18);
g.setFont(font);String name = type[f]+" "+ stylenames[s];
g.drawString(name,20,(f *4+ s +1)*20);}}}publicstaticvoidmain(String[] a){JFrame f =newJFrame();
f.addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvent e){System.exit(0);}});
f.setContentPane(newMain());
f.setSize(400,400);
f.setVisible(true);}}