java - 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 通常那样显示画布。
解决方案
推荐阅读
- python - 如何修复索引中的列表?
- mysql - CAST() 函数 MYSQL 似乎对我不起作用?请需要帮助
- javascript - 一个 Javascript 过滤器按钮,帮助完成它吗?
- vb.net - 如何在网络浏览器中收集和保存所有图像?VB.NET
- selenium-webdriver - 如何使用夜间构建配置 Selenium c#(SpecFlow、Nunit、DotnetProject)
- python - 最小化同一函数定义同步和异步之间的重复
- python-3.x - 为什么我的程序抛出异常'xyz'不是一个包?
- typescript - 使用打字稿获取字段类型而不创建实例
- c# - SpecFlow - StepArgumentTransformation System.InvalidCastException:“对象必须实现 IConvertible。”
- sql - SQL 查询——跨多列出现的 AVG