- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因此,我像往常一样运行一个小程序,在左下角显示“在 appletviewer 中执行小程序”时,它会保留在那里,而 appletviewer 永远不会打开。当我右键单击该类时,“运行小程序”呈红色(如果这很重要的话)。我已经卸载了计算机上与 Java 相关的所有内容,并多次重新安装了 JDK 7 以及 BlueJ,但仍然得到 appletviewer 未弹出的结果。我一直尝试的小程序类是直接来 self 的教科书网站的,所以我猜代码没有任何问题。该小程序与我学校其他人的计算机运行良好。那么我该怎么做才能让 appletviewer 工作呢?
这是该类的代码:
import javax.swing.JApplet;
import java.awt.*;
public class Snowman extends JApplet
{
public void paint (Graphics page)
{
final int MID = 150;
final int TOP = 50;
setBackground (Color.cyan);
page.setColor (Color.blue);
page.fillRect (0, 175, 300, 50); // ground
page.setColor (Color.yellow);
page.fillOval (-40, -40, 80, 80); // sun
page.setColor (Color.white);
page.fillOval (MID-20, TOP, 40, 40); // head
page.fillOval (MID-35, TOP+35, 70, 50); // upper torso
page.fillOval (MID-50, TOP+80, 100, 60); // lower torso
page.setColor (Color.black);
page.fillOval (MID-10, TOP+10, 5, 5); // left eye
page.fillOval (MID+5, TOP+10, 5, 5); // right eye
page.drawArc (MID-10, TOP+20, 20, 10, 190, 160); // smile
page.drawLine (MID-25, TOP+60, MID-50, TOP+40); // left arm
page.drawLine (MID+25, TOP+60, MID+55, TOP+60); // right arm
page.drawLine (MID-20, TOP+5, MID+20, TOP+5); // brim of hat
page.fillRect (MID-15, TOP-20, 30, 25); // top of hat
}
}
最佳答案
确保在运行之前导入小程序类。这可能与你的问题有关。导入 java.applet.;导入 java.awt.;
关于java - BlueJ 中的 Appletviewer 无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12432927/
这个问题已经有答案了: "No X11 DISPLAY variable" - what does it mean? (12 个回答) 已关闭 7 年前。 Exception in threa
C:\Users\ms536\Desktop\java>appletviewer awt_ex.java 'appletviewer' is not recognized as an internal
C:\Users\ms536\Desktop\java>appletviewer awt_ex.java 'appletviewer' is not recognized as an internal
我正在使用 Java Applet 开发一款游戏,本打算在 JDK AppletViewer 中玩,但我遇到了一个问题。在玩上面的游戏时,小程序底部的状态栏(显示“小程序已启动”的棕色状态栏)看起来很
我的代码在我的浏览器和 Eclipse 中编译和工作都很好,但由于某些原因,AppletViewer 不能与我的非常简单的代码一起工作。当我尝试使用 appletviewer FirstApplet.
当我的小程序第一次从干净的环境中启动时,一切都按照我期望的方式工作。我产生了两个线程,一个用于通用处理,一个用于图形处理。我从事件分派(dispatch)线程执行所有 GUI 操作调用。启动/停止从
因此,我像往常一样运行一个小程序,在左下角显示“在 appletviewer 中执行小程序”时,它会保留在那里,而 appletviewer 永远不会打开。当我右键单击该类时,“运行小程序”呈红色(如
当我从 appletviewer 运行 Main00App.java 时,我有 开始:小程序未启动。阅读注释的 html 是因为我可以使用宽度和高度调整窗口大小。 import java.awt.*;
JDK12 中有小程序查看器的替代方案吗? 我是 Java 新手,我尝试在 Java 中添加 AWT 复选框在 JDK 1.8 中运行良好,但在 JDK12 中运行不佳。 我在互联网上搜索,发现小程序
当我在我的 Mavericks Mac 上运行以下命令时: appletviewer index.html appletviewer 进程启动,但没有窗口显示实际的 applet,我需要在进程上使用
我创建了一个 Java 小程序并编译了它。作为编译的结果,它生成了一个 class 文件。但是,它在使用 appletviewer 命令在命令提示符下运行小程序时显示以下警告消息。 D:\Applet
我正在尝试解决无法在 appletviewer 下运行的已签名 jar 的问题。我的主要目标是在浏览器之外运行它,所以我尝试使用 appletviewer - 如果您有其他建议,请告诉我。 这是上下文
我是 Java 新手,我有一个小程序项目要为学校做,现在已经全部完成了。当我通过 appletviewer 命令行运行它时它工作正常,但是当我通过浏览器预览它时,图像不显示。 简而言之,我的应用程序必
我刚刚在网页中执行小程序时遇到了麻烦:弹出错误对话框: 计算器是我的类名,Exercise4 是包含它的文件夹。我确信html 文件和calculator.class 位于名为Exercise4 的同
在AppletViewer中,我的Applet看起来像这样: 在浏览器中,我的小程序如下所示: 如您所见,字体没有抗锯齿。而且背景颜色也不一样。所有文本都在右侧被剪切。 那可能是什么? 您也可以自己尝
在开始之前,我知道我应该使用 Swing 而不是 AWT,但这就是我正在使用的书所教的内容,所以我现在就使用它。 现在,我的问题是为什么 AppletViewer 可以正常运行此代码,但我尝试过的每个
我正在尝试学习 Java,但在使用 appletviewer 命令时遇到了问题。我正在使用 openSUSE 11 并且能够编译和运行普通的 Java 程序,但是当我发出 appletviewer 命
当我在浏览器中使用此小程序时,它工作正常,但为什么它不能在小程序查看器中工作? 我尝试使用 jGRASP 和 Eclipse 来查看小程序,但无论我做什么,我都会得到这个: java.lang.Num
对于我的 CS11 类(class),我必须编写一个小小程序,用于在屏幕上绘制一条在 Canvas 中间相交的水平线和垂直线。分配的一部分是当用户单击一行并执行拖动时能够移动一条或两条线。该部分正在工
我正在做一个名为“电磁场曲棍球”的个人项目(以 The University of Colorado's PhET website 上的电场曲棍球命名)。我决定将该应用程序移植到我网站上的 Java
我是一名优秀的程序员,十分优秀!