{请您尽快修改您的贴名------------already changed }
DrawNoCanvas.java
运行结果特别的奇怪,各位研究一下
源代码如下:
import java.awt.*;
import java.awt.event.*;
public class DrawNoCanvas
extends Frame {
private Button button = new Button("draw");
private class WindowCloser
extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
public DrawNoCanvas() {
super("NoCanvas");
Panel panel = new Panel();
panel.setLayout(new FlowLayout());
panel.add(button);
setLayout(new BorderLayout());
add("Center", panel);
setSize(150, 150);
setVisible(true);
addWindowListener(new WindowCloser());
}
public void paint(Graphics g) {
for (int i = 12; i < getSize().height; i = +12) {
g.drawString("y location: " + i, 10, i);
}
}
public static void main(String argv []) {
DrawNoCanvas drawNoCanvas=new DrawNoCanvas();
}
}