canvasdemo_gui.java
来自「JAVA程序设计课程中各章节的程序实例。」· Java 代码 · 共 41 行
JAVA
41 行
/**
*A simple canvas prigram in GUI
*2004.11.26. xhcprince
*pay mre attention to this program!!!
*/
import java.awt.*;
import java.applet.*;
public class canvasDemo_GUI extends Applet
{
private canvas obj;
public void init()
{
obj = new canvas(200,200);
this.add(obj);
}
}
class canvas extends Canvas
{
protected canvas(int width, int height)
{
super();
this.setSize(width,height);
}
public void paint(Graphics g)
{
int width = this.getBounds().width;
int height = this.getBounds().height;
g.drawLine(0,0,width,height);
g.drawLine(0,height,width,0);
}
}
/*
<applet code = "canvasDemo_GUI.class" width = 600 height = 300>
</applet>
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?