要放在html里面才能运行的
直接用jbuilder或者java.exe来运行当然不行了。
直接用jbuilder或者java.exe来运行当然不行了。
解决方案 »
- 如何让多个组件复用弹出菜单JPopupMenu?
- 请交各位大虾,java里面怎样通过一个父类得到它所有的子类呢
- 如何在程序中得出一张表的详细内容?比如主键,外键,什么的
- 一个关于exe4j的问题 请各位大虾帮帮忙!
- 谁知道Bits和LinkedList这2个类是做什么的?麻烦您说一下!!
- 请问在哪儿可以下载到dom4j包?
- 算是文件加密的问题吧!(急!!!)
- 有人试过Domino和Tomcat配合使用吗?
- 关于子类继承父类的问题,很简单的。进来看看吧
- 一个基本问题,但需要高手指点。。水平不够者勿误导
- 还没搞懂,麻烦赐教!
- 如何提取从搜索引擎返回的大量页面中的有用的链接,是一个个的分析提取,还是有针对搜索引擎的有规律的方法。
直接用jbuilder或者java.exe来运行当然不行了。
或者用 Appletviewer 运行
<applet width="450" height="300" code="SquareInt.class">
</applet>
但是我也没有看到你重载void paint(Graphics g)方法呀
public void init()
中间加上
public void paint(Graphics g) {
然后在你的SquareInt.class同目录下建一个html文件﹐用
<applet width="450" height="300" code="SquareInt.class">
</applet>
嵌入﹐然后执行这个html文件就可以显示了。
the result of 1is 1/n the result of 2is 4/n the result 3is 9/n.....
若想在java程序运行里面显示,可以将这个程序片窗口放入一个Frame界面显示其结果,添加代码如下:
在程序头添加:
import java.awt.*;
import java.awt.event.*;
在程序尾最后一个}符号前添加:
// To close the application:
static class WL extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
// A main() for the application:
public static void main(String[] args) {
SquareInt applet = new SquareInt();
Frame aFrame = new Frame("SquareInt");
aFrame.addWindowListener(new WL());
aFrame.add(applet, BorderLayout.CENTER);
aFrame.setSize(300,200);
applet.init();
applet.start();
aFrame.setVisible(true);
}此程序执行结果为:
The result of 1is 1/nThe result of 2is 4/nThe result of 3is 9/nThe result of 4is 16/nThe result of 5is 25/nThe result of 6is 36/nThe result of 7is 49/nTh……