private Font myFont = new Font("Serif",Font.PLAIN,8);
建立一个文本对象MyLable.setFont(myFont);

解决方案 »

  1.   

    import java.awt.*;
    import java.awt.event.*;
    public class EventTest
    {
         public static void main(String args[])
         {      
            Frame fr=new Frame("事件测试");
            ButtonListener aa =new ButtonListener();
            Button b1 =new Button("测试");
            Button b2 =new Button("退出");
            b1.addActionListener(aa);
            b2.addActionListener(aa);
            fr.setBackground(Color.red);
            fr.setForeground(Color.blue);
            fr.setEnabled(true);
            fr.setFont();\\这里的问题?/
            fr.setLayout( new FlowLayout());
            fr.add(b1);
            fr.add(b2);
            fr.resize(200,200);
            fr.show();
           }
    }
    class ButtonListener implements ActionListener
    {
           public void actionPerformed(ActionEvent e)
           {
               if (e.getActionCommand()=="测试")
               {
                  System.out.println("你好,小黑三!!!");
               }
               else
               {
                    System.exit(0);
                }
             } 
    }