import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
import javax.swing.JPanel;
public class Grid extends JComponent
{
public void paint(Graphics g){
super.paintComponent(g);
Graphics2D graphics = (Graphics2D) g;
int w = 1024*2;
int h = 1024*2;
for(int i=0; i<1024; i++)
{
graphics.drawLine(i, 0, i, 1024);
//graphics.setColor(Color.red);
}
for(int j=0; j<1024; j++)
{
graphics.drawLine(0, j, 1024, j);
}
}
}
我需要绘制 1024 个跨 1024 个单元格并为少数单元格着色。单元格应显示在 JFrame 上。在java中最好的方法是什么?请贴一些代码...