/*这是那个该死的程序 
 *@(#)Headlinee.java  1.0  2003/03/12
 *
 * Copyright (c) Since 2003 WisdomLeague  
 *
 */
/**
 *
 *@version      1.0   23 March 2003
 *@author   Fan
 */ import java.awt.*;
 import javax.swing.*;
 import java.util.*; public class Headlines extends JFrame {
     HeadlinePanel news = new HeadlinePanel();
     public Headlines() {
         super("Headline");
         setSize(420,100);
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         JPanel pane = new JPanel();
         pane.setLayout(new GridLayout(1,1,15,15));
         pane.add(news);
         setContentPane(pane);
         show();
         news.scroll();
     }     public static void main(String[] arguments) {
         Headlines head = new Headlines();
     }
 } class HeadlinePanel extends JPanel  {
     String[] headlines = {
     "Grandmother of Eight Makes Hole in on",
     "Police Begin Campaign to Run Down Jaywalkers",
     "Dr.Rush to Talk About Sex with Newspaper Editors",
     "Enraged Cow Injures Farmers with axe"
     };
     int y = 76;
 } void scroll() {
     while (true) {
         y = y-1;
         if( y < -75 )
             y = 76;
         repaint();
         try {
             Thread.sleep(250);
         } catch (InterruptedException e) { }
     }
 } public void paintCompont(Graphics comp) {
     Graphics2D comp2D = (Graphics2D)comp;
     Font type = new Font("monospaced", Font.BOLD, 14);
     comp2D.setFont(type);
     comp2D.setColor(getBackground());
     comp2D.fillRect(0, 0, getSize().width, getSize().height);
     comp2D.setColor(Color.black);
     for ( int i = 0 ; i<headlines.length; i++)
         comp2D.drawString (headlines[i], 5, y+(20*i));
     
 }

解决方案 »

  1.   

    import java.awt.*;
     import javax.swing.*;
     import java.util.*; public class Headlines extends JFrame {
         HeadlinePanel news = new HeadlinePanel();
         public Headlines() {
             super("Headline");
             setSize(420,100);
             setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             JPanel pane = new JPanel();
             pane.setLayout(new GridLayout(1,1,15,15));
             pane.add(news);
             setContentPane(pane);
             show();
             news.scroll();
         }     public static void main(String[] arguments) {
             Headlines head = new Headlines();
         }
     } class HeadlinePanel extends JPanel  {
         String[] headlines = {
         "Grandmother of Eight Makes Hole in on",
         "Police Begin Campaign to Run Down Jaywalkers",
         "Dr.Rush to Talk About Sex with Newspaper Editors",
         "Enraged Cow Injures Farmers with axe"
         };
         int y = 76;
     void scroll() {
         while (true) {
             y = y-1;
             if( y < -75 )
                 y = 76;
             repaint();
             try {
                 Thread.sleep(250);
             } catch (InterruptedException e) { }
         }
     } public void paintCompont(Graphics comp) {
         Graphics2D comp2D = (Graphics2D)comp;
         Font type = new Font("monospaced", Font.BOLD, 14);
         comp2D.setFont(type);
         comp2D.setColor(getBackground());
         comp2D.fillRect(0, 0, getSize().width, getSize().height);
         comp2D.setColor(Color.black);
         for ( int i = 0 ; i<headlines.length; i++)
             comp2D.drawString (headlines[i], 5, y+(20*i)); }
    }这样就可以了,把“int y = 76;”下面的“}”搬到最后。
      

  2.   

    /*这个程序不该死,主要是你的花括号放错位置了 
     *@(#)Headlinee.java  1.0  2003/03/12
     *
     * Copyright (c) Since 2003 WisdomLeague  
     *
     */
    /**
     *
     *@version      1.0   23 March 2003
     *@author   Fan
     */ import java.awt.*;
     import javax.swing.*;
     import java.util.*; public class Headlines extends JFrame {
         HeadlinePanel news = new HeadlinePanel();
         public Headlines() {
             super("Headline");
             setSize(420,100);
             setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             JPanel pane = new JPanel();
             pane.setLayout(new GridLayout(1,1,15,15));
             pane.add(news);
             setContentPane(pane);
             show();
             news.scroll();
         }     public static void main(String[] arguments) {
             Headlines head = new Headlines();
         }
     } class HeadlinePanel extends JPanel  {
         String[] headlines = {
         "Grandmother of Eight Makes Hole in on",
         "Police Begin Campaign to Run Down Jaywalkers",
         "Dr.Rush to Talk About Sex with Newspaper Editors",
         "Enraged Cow Injures Farmers with axe"
         };
         int y = 76;
    //这里原来有一个}
     void scroll() {
         while (true) {
             y = y-1;
             if( y < -75 )
                 y = 76;
             repaint();
             try {
                 Thread.sleep(250);
             } catch (InterruptedException e) { }
         }
     } public void paintCompont(Graphics comp) {
         Graphics2D comp2D = (Graphics2D)comp;
         Font type = new Font("monospaced", Font.BOLD, 14);
         comp2D.setFont(type);
         comp2D.setColor(getBackground());
         comp2D.fillRect(0, 0, getSize().width, getSize().height);
         comp2D.setColor(Color.black);
         for ( int i = 0 ; i<headlines.length; i++)
             comp2D.drawString (headlines[i], 5, y+(20*i));
         
     }
    }//把上面的}放到这里就可以了