首页 > 解决方案 > BlueJ 和 Java 运行程序的基本问题

问题描述

我想运行一个程序,到目前为止,该课程只有一个单一的调用来在画布上放置大教堂的图像。然而,在代码的底部有一个创建和运行程序的命令(CHApplet)。这应该使整个事情执行得很好,但它给了我一个令人困惑的白屏,上面什么都没有

这是代码:

import cha.*;
import cha.action.*;
import java.awt.*;
import javax.swing.*;
import java.util.*;
import static java.awt.Color.*;

/**
 * Setting
 *
 * Arch Morrison
 * v1
 */
public class Cathedral
extends CHApplet
{
    public void init() {

      CHImage cathedral;
      cathedral = new CHImage();
      add(cathedral);
      cathedral.setFile("cathedral.jpg");
      cathedral.setBounds(0, 0, 600, 600);

    }

    public static void run() {
        CHApplet applet;
        applet = new CHApplet();
        int width = 600;
        int height = 600;
        CHApplet apply = new Cathedral();
        applet.run(width, height);
    }

     private Cathedral() {
        }
}

我应该提到没有错误消息,代码编译并运行,但不像 BlueJ 通常那样显示画布。

空 Applet 的图像

标签: javabluej

解决方案


推荐阅读