Applet未初始化

时间:2016-03-23 20:31:22

标签: java swing applet initialization

我不确定出了什么问题。我对Java很陌生,而且我可能会倒退这个项目。无论如何,这个任务是创建一个小程序,显示5个不同的电影,他们的封面,标题,导演和他们被释放的年限。我们假设通过创建两个不同的类来完成此操作。

所以,我已经完成了这项工作,编译了全部,没有错误,但是当我运行它时,它说"开始:Applet未初始化"。

这是我的帮助班"

import java.awt.*;
import javax.swing.*;

public class MovieInfo extends JComponent
{
    JLabel title, director, year, poster;
    Image img;
    ImageIcon imgIcon;
    JTextField titleTF, directorTF, yearTF;
    String m_title, m_director, m_year;
    JPanel pane;



public MovieInfo(Image cover, String x, String y, String z)
{
    setLayout( new BorderLayout());

    img = cover;
    imgIcon = new ImageIcon (img);
    poster = new JLabel (imgIcon);
    title = new JLabel ("Title:");
    director = new JLabel ("Director:");
    year = new JLabel ("Year:");
    m_title = x;
    m_director = y;
    m_year = z;
    titleTF.setText("x");
    directorTF.setText("y");
    yearTF.setText("z");


    add (poster, BorderLayout.NORTH);

    pane = new JPanel(new GridLayout(3, 2));
    pane.add(title);    pane.add(titleTF);
    pane.add(director); pane.add(directorTF);
    pane.add(year);     pane.add(yearTF);

    add(pane, BorderLayout.CENTER);
    }
}

这是我的其他课程

import java.awt.*;
import javax.swing.*;

public class MovieDisplay extends JApplet
{
    Image img;
    MovieInfo labyrinth, overboard, megamind, narnia, beetlejuice;

public void init()
{
    setLayout(new BorderLayout());

    LabyrinthInfo();
    OverboardInfo();
    MegamindInfo();
    NarniaInfo();
    BeetlejuiceInfo();
}
public void LabyrinthInfo()
{
    img = getImage( getCodeBase(), "Labyrinth.jpg");
    labyrinth = new MovieInfo(img, "Labyrinth", "Jim Henson", "1986");
}
public void OverboardInfo()
{
    img = getImage( getCodeBase(), "Overboard.jpg");
    overboard = new MovieInfo(img, "Overboard", "Garry Marshall", "1987");
}
public void BeetlejuiceInfo()
{
    img = getImage( getCodeBase(), "Beetlejuice.jpg");
    beetlejuice = new MovieInfo(img, "Beetlejuice", "Tim Burton", "1988"); 
}
public void NarniaInfo()
{
    img = getImage( getCodeBase(), "Narnia.jpg");
    narnia = new MovieInfo(img, "Narnia - The Lion, the witch, and the wardrobe", "Andrew Adamson", "2005"); 
}
public void MegamindInfo()
{
    img = getImage( getCodeBase(), "Megamind.jpg");
    megamind = new MovieInfo(img, "Megamind", "Tom McGrath", "2010");
    }
}

0 个答案:

没有答案