使用HTML5 eclipse获取applet类

时间:2015-07-18 16:25:03

标签: java eclipse html5 applet

我有以下代码:

public void loadNextFlag() {
    startTimer();
    String timerDisplayString;
    oneImageView.setVisibility(View.INVISIBLE);
    showTimer("loadNextFlag");
    currentTimeSpent = timeStringToMillis(Timer.getTimerString());// was prevTimeSpent--7/17/15--DAS
    InputStream stream ;
    // get file name of the next flag and remove it from the list
    consecutiveWrong = 0;

    String nextImage = quizFlagPathList.remove(0);
    correctAnswer = nextImage; // update the correct answer
    answerImageView.setVisibility(View.INVISIBLE);
    ableButtons(true);

    // display current question number--2nd and 3rd parameters are INPUT into the xml statement
    questionNumberTextView.setText(getResources().getString(R.string.question,
            (correctAnswers + 1),
            FLAGS_IN_QUIZ));
    // extract the region from the next image's name
    String region = nextImage.substring(0, nextImage.indexOf('-'));

    // use AssetManager to load next image from assets folder
    AssetManager assets = getActivity().getAssets();

    try{
        stream = assets.open(region + "/" + nextImage + ".png");

        Drawable flag = Drawable.createFromStream(stream, nextImage);
        flagImageView.setImageDrawable(flag);
    }catch (IOException exception){Log.w(TAG, "Error loading " + nextImage, exception);}

    Collections.shuffle(flagPathList); // shuffle file names

    // put the correct answer at the end of flagPathList
    int correct = flagPathList.indexOf(correctAnswer);

    flagPathList.add(flagPathList.remove(correct));

    int k = 0;
    countriesToUse.clear();
    for(int row = 0; row < guessRows; row++)
        for (int col = 0; col < guessLinearLayouts[row].getChildCount(); col++)
            countriesToUse.add(getCountryName(flagPathList.get(k++)));

    countriesToUse.set(countriesToUse.size() - 1, getCountryName(flagPathList.get(flagPathList.size() - 1)));

    if(MainActivity.getAlphabetize()) Collections.sort   (countriesToUse);
    else                              Collections.shuffle(countriesToUse);

    k = 0;
    // add 3, 6, or 9 guess Buttons based on the value of guessRows
    for (int row = 0; row < guessRows; row++) {
        // place Buttons in currentTableRow
        for (int column = 0; column < guessLinearLayouts[row].getChildCount(); column++) {
            // get reference to Button to configure
            Button newGuessButton = (Button) guessLinearLayouts[row].getChildAt(column);
            newGuessButton.setEnabled(true);
            // get country name and set it as newGuessButton's text
            String fileName = countriesToUse.get(k++);
            newGuessButton.setText((fileName));
        }
    }
} // end method loadNextFlag

我想在html5页面上调用它,目前为止如下代码:

@SuppressWarnings("serial") 
public class AppletImage extends Applet {   
 Image picture;

 public void init() {       
   picture = getImage(getDocumentBase(), "slider_front_img.png");
 }
 public void paint(Graphics g) {        
   g.drawImage(picture, 10, 10, this);  
 } 
}

当我在Firefox上运行它时会启动一个应用程序错误,说“class not found exception”。我找不到哪些包可能是错的。

Code structure on eclipse

0 个答案:

没有答案