import java.awt.event.*;
import java.awt.*;
import java.applet.*;
public class Picture extends Applet  implements ItemListener {
    
    private Choice C1;
private String S1[],S2[];
private int totalPics;
private Image offI,img[];
private MediaTracker imagetracker;

   
public void init()
{
this.setLayout(null);
C1 = new Choice();
C1.setBounds(30,70,100,20);
C1.setBackground(Color.cyan);
C1.setFont(new Font("宋体",Font.PLAIN+Font.BOLD,14));
C1.addItemListener(this);
totalPics = Integer.parseInt(getParameter("TotalPic"));
S1 = new String[totalPics];
S2 = new String[totalPics];
img = new Image[totalPics];
for(int i=0; i<totalPics; i++)
{ S1[i] = new String("");
}
String s = new String("");
imagetracker = new MediaTracker(this);
for(int i=0; i<totalPics; i++)
{ s = getParameter("Text" + (i+1));  
S1[i] = s;
C1.add(s);
s = getParameter("Picture" + (i+1));  
img[i] = getImage(getDocumentBase(), s);
imagetracker.addImage(img[i],0);
}
add(C1);
offI = createImage(size().width,size().height);
}
  
public void paint(Graphics g)
{

g.setColor(Color.black);
        g.drawRoundRect(10,10,300,300,20,20);
        g.setColor(Color.orange);
        g.fillRoundRect(10,10,300,300,20,20);
        g.setColor(Color.black);
g.drawOval(50,20,200,35);
g.setColor(Color.white);
g.fillOval(50,20,200,35);
g.setColor(Color.blue);
g.setFont(new Font("隶书",Font.PLAIN+Font.BOLD,24));
g.drawString("我的风景相册",80,45);
g.setColor(Color.blue);
g.drawLine(30,60,290,60);
g.drawLine(30,63,290,63);
g.setColor(Color.black);
g.drawRect(30,100,260,190);
g.setColor(Color.lightGray);
g.fillRect(30,100,260,190);
g.drawImage(offI,35,105,this);
}运行javac的时候就会提示说Picture.java:66进行语法解析时已经达到文件结尾!
我编写程序问题出现在那里了啊???

解决方案 »

  1.   


    import java.awt.event.*;
    import java.awt.*;
    import java.applet.*;public class Picture extends Applet implements ItemListener {    private static final long serialVersionUID = 1L;    private Choice C1;    private String S1[], S2[];    private int totalPics;    private Image offI, img[];    private MediaTracker imagetracker;    public void init() {
            this.setLayout(null);
            C1 = new Choice();
            C1.setBounds(30, 70, 100, 20);
            C1.setBackground(Color.cyan);
            C1.setFont(new Font("宋体", Font.PLAIN + Font.BOLD, 14));
            C1.addItemListener(this);
            totalPics = Integer.parseInt(getParameter("TotalPic"));
            S1 = new String[totalPics];
            S2 = new String[totalPics];
            img = new Image[totalPics];
            for (int i = 0; i < totalPics; i++) {
                S1[i] = new String("");
            }
            String s = new String("");
            imagetracker = new MediaTracker(this);
            for (int i = 0; i < totalPics; i++) {
                s = getParameter("Text" + (i + 1));
                S1[i] = s;
                C1.add(s);
                s = getParameter("Picture" + (i + 1));
                img[i] = getImage(getDocumentBase(), s);
                imagetracker.addImage(img[i], 0);
            }
            add(C1);
            offI = createImage(size().width, size().height);
        }    public void paint(Graphics g) {        g.setColor(Color.black);
            g.drawRoundRect(10, 10, 300, 300, 20, 20);
            g.setColor(Color.orange);
            g.fillRoundRect(10, 10, 300, 300, 20, 20);
            g.setColor(Color.black);
            g.drawOval(50, 20, 200, 35);
            g.setColor(Color.white);
            g.fillOval(50, 20, 200, 35);
            g.setColor(Color.blue);
            g.setFont(new Font("隶书", Font.PLAIN + Font.BOLD, 24));
            g.drawString("我的风景相册", 80, 45);
            g.setColor(Color.blue);
            g.drawLine(30, 60, 290, 60);
            g.drawLine(30, 63, 290, 63);
            g.setColor(Color.black);
            g.drawRect(30, 100, 260, 190);
            g.setColor(Color.lightGray);
            g.fillRect(30, 100, 260, 190);
            g.drawImage(offI, 35, 105, this);
        }    public void itemStateChanged(ItemEvent e) {
            // TODO Auto-generated method stub
            
        }
    }
      

  2.   

    谢谢你的回答但是,出现了新的提示
    1注意:Picture.java使用或覆盖了已经过时的API
    2注意:要了解详细信息,请使用-xlint:deprecation重新编译。对于我这样的新手是一头雾水啊!
      

  3.   

    提示没有问题 不报错就行 你可以在private String S1[], S2[];上面加上@SuppressWarnings("unused")
    在public void init()方法上加@SuppressWarnings("unused")因为size()方法已过时
    还有最好还是用eclipse或者myeclipse把