返回信息流附件(959B) DisplayGrid.java
代码已上传
文件在Jcreator中可以运行,但在命令窗口却提示错误??
为什么呢?
import java.awt.Graphics;
import javax.swing.*;
public class DisplayGrid extends JFrame{
public DisplayGrid(){
// Using panel to draw a grid
add(new GridPanel(3, 3));
}
public static void main(String[] args){
DisplayGrid frame = new DisplayGrid();
frame.setTitle("DisplayGrid");
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(150, 150);
frame.setVisible(true);
}
}
class GridPanel extends JPanel{
private int row;
private int column;
public GridPanel(int row, int column){
super();
this.row = row;
this.column = column;
}
protected void paintComponent(Graphics g){
super.paintComponent(g);
int width = getWidth();
int height = getHeight();
for(int x = 0; x <= width; x += width / column)
g.drawLine(x, 0, x, height);
for(int y = 0; y <= height; y += height / row)
g.drawLine(0, y, width, y);
}
}
这是一条镜像帖。来源:北邮人论坛 / java / #12360同步于 2009/11/22
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
[求助]为什么提示类不存在呢?(明明有啊?)
keroro
2009/11/22镜像同步5 回复
订阅后,新回复会通过你的通知中心匿名送达。